lib/memory-engine.js
function createOrUpdate(object, callback) {
    if (typeof object[options.idProperty] === 'undefined') {
      // Create a new object
      self.create(object, callback)
    } else {
      // Try and find the object first to update
      var query = {}
      query[options.idProperty] = object[options.idProperty]

      self.findOne(query, function (err, foundObject) {
        if (foundObject) {
          // We found the object so update
          self.update(object, callback)
        } else {
          // We didn't find the object so create
          self.create(object, callback)
        }
      })
    }
  }
function createOrUpdate(object, callback) {
    if (typeof object[options.idProperty] === 'undefined') {
      // Create a new object
      self.create(object, callback)
    } else {
      // Try and find the object first to update
      var query = {}
      query[options.idProperty] = object[options.idProperty]

      self.findOne(query, function (err, foundObject) {
        if (foundObject) {
          // We found the object so update
          self.update(object, callback)
        } else {
          // We didn't find the object so create
          self.create(object, callback)
        }
      })
    }
  }
function createOrUpdate ( object , callback ) { if ( typeof object [ options . idProperty ] === 'undefined' ) { // Create a new object self . create ( object , callback ) } else { // Try and find the object first to update var query = { } query [ options . idProperty ] = object [ options . idProperty ] self . findOne ( query , function ( err , foundObject ) { if ( foundObject ) { // We found the object so update self . update ( object , callback ) } else { // We didn't find the object so create self . create ( object , callback ) } } ) } }
Create or update a entity. Emits a 'create' event or a 'update'.

@param {Object} object to create or update
@param {Function} callback (optional)
@api public
Create or update a entity . Emits a create event or a update .