@@ -58,7 +58,11 @@ var ObservationSchema = new Schema({
5858 } ,
5959 favoriteUserIds : [ { type : Schema . Types . ObjectId , ref : 'User' } ]
6060} , {
61- strict : false
61+ strict : false ,
62+ timestamps : {
63+ createdAt : 'createdAt' ,
64+ updatedAt : 'lastModified'
65+ }
6266} ) ;
6367
6468ObservationSchema . index ( { geometry : "2dsphere" } ) ;
@@ -237,8 +241,6 @@ exports.getObservations = function(event, o, callback) {
237241
238242// DEPRECATED backwards compat for creating an observation. Will be removed in version 5.x.x
239243exports . createObservation = function ( event , observation , callback ) {
240- observation . lastModified = moment . utc ( ) . toDate ( ) ;
241-
242244 observationModel ( event ) . create ( observation , callback ) ;
243245} ;
244246
@@ -263,8 +265,6 @@ exports.getObservationById = function(event, observationId, options, callback) {
263265} ;
264266
265267exports . updateObservation = function ( event , observationId , observation , callback ) {
266- observation . lastModified = moment . utc ( ) . toDate ( ) ;
267-
268268 observationModel ( event ) . findByIdAndUpdate ( observationId , observation , { new : true , upsert : true } , callback ) ;
269269} ;
270270
@@ -318,9 +318,6 @@ exports.addState = function(event, id, state, callback) {
318318 '$each' : [ state ] ,
319319 '$position' : 0
320320 }
321- } ,
322- '$set' : {
323- lastModified : moment . utc ( ) . toDate ( )
324321 }
325322 } ;
326323
@@ -333,9 +330,6 @@ exports.addFavorite = function(event, observationId, user, callback) {
333330 var update = {
334331 $addToSet : {
335332 favoriteUserIds : user . _id
336- } ,
337- '$set' : {
338- lastModified : moment . utc ( ) . toDate ( )
339333 }
340334 } ;
341335
@@ -346,9 +340,6 @@ exports.removeFavorite = function (event, observationId, user, callback) {
346340 var update = {
347341 $pull : {
348342 favoriteUserIds : user . _id
349- } ,
350- '$set' : {
351- lastModified : moment . utc ( ) . toDate ( )
352343 }
353344 } ;
354345
@@ -359,9 +350,6 @@ exports.removeImportant = function(event, id, callback) {
359350 var update = {
360351 '$unset' : {
361352 important : 1
362- } ,
363- '$set' : {
364- lastModified : moment . utc ( ) . toDate ( )
365353 }
366354 } ;
367355
@@ -396,7 +384,7 @@ exports.addAttachment = function(event, id, file, callback) {
396384 lastModified : new Date ( )
397385 } ) ;
398386
399- var update = { '$push' : { attachments : attachment } , 'lastModified' : new Date ( ) } ;
387+ var update = { '$push' : { attachments : attachment } } ;
400388 observationModel ( event ) . update ( condition , update , function ( err ) {
401389 callback ( err , attachment ) ;
402390 } ) ;
0 commit comments