@@ -13,9 +13,7 @@ function Backend() {}
13
13
util . inherits ( Backend , baseBackend ) ;
14
14
15
15
Backend . prototype . serializeValue = function ( value ) {
16
- throw new Error (
17
- 'Cant serialize for waterline since model.identity is not accessible from the instance' ,
18
- ) ;
16
+ throw new Error ( 'Cant serialize for waterline since model.identity is not accessible from the instance' ) ;
19
17
// if (typeof (value._id) != 'undefined') {
20
18
// return value.constructor.modelName + ':' + value.id;
21
19
// } else {
@@ -68,76 +66,3 @@ Backend.prototype.getClassFromRef = function(ref) {
68
66
Backend . prototype . getIdFromRef = function ( ref ) {
69
67
return ref . split ( ':' ) [ 1 ] ;
70
68
} ;
71
-
72
- // function getReferencePaths(paths) {
73
- // var names = [];
74
- // for (var k in paths) {
75
- // if (paths[k].instance === 'ObjectID' && k !== 'id') {
76
- // names.push(paths[k].path);
77
- // }
78
- // }
79
-
80
- // return names.join(' ');
81
- // }
82
-
83
- /*
84
-
85
- We could do this using lodash.merge
86
- https://lodash.com/docs/4.16.1#merge
87
- in combination with these lifecycle objects
88
- http://sailsjs.org/documentation/concepts/models-and-orm/lifecycle-callbacks
89
- afterCreate
90
- afterDestroy
91
-
92
- Could bind the model.identity so that in case we actually know the identity
93
-
94
- var mongooseActivitySchemaPlugin = function(schema, options) {
95
- schema.pre('save', function(next) {
96
- this.wasNew = this.isNew;
97
- next();
98
- });
99
-
100
- schema.post('save', function(doc) {
101
- var paths = getReferencePaths(doc.schema.paths);
102
- doc.populate(paths, function(err, docP) {
103
- if (docP.wasNew) {
104
- stream.FeedManager.activityCreated(docP);
105
- }
106
- });
107
- });
108
-
109
- schema.post('remove', function(doc) {
110
- var paths = getReferencePaths(doc.schema.paths);
111
- doc.populate(paths, function(err, docP) {
112
- stream.FeedManager.activityDeleted(docP);
113
- });
114
- });
115
-
116
- // add Mongoose specific proto functions
117
- schema.methods.referencesPaths = function() {
118
- return this;
119
- };
120
-
121
- schema.methods.getStreamBackend = function() {
122
- return new Backend();
123
- };
124
-
125
- schema.statics.activityModelReference = function() {
126
- return this.modelName;
127
- };
128
-
129
- schema.methods.activityVerb = function() {
130
- return this.constructor.modelName;
131
- };
132
-
133
- schema.statics.pathsToPopulate = function() {
134
- return [];
135
- };
136
- };
137
-
138
- module.exports.activity = function(schema, options) {
139
- schema.plugin(baseActivitySchemaPlugin);
140
- schema.plugin(mongooseActivitySchemaPlugin);
141
- };*/
142
-
143
- module . exports . Backend = Backend ;
0 commit comments