lib/memory-engine.js
function create(object, callback) {
    self.emit('create', object)
    callback = callback || emptyFn
    // clone the object
    var extendedObject = extend({}, object)

    if (!extendedObject[options.idProperty]) {
      idSeq += 1
      extendedObject[options.idProperty] = '' + idSeq
    } else {
      if (findById(extendedObject[options.idProperty]) !== null) {
        return callback(new Error('Key ' + extendedObject[options.idProperty] + ' already exists'))
      }
      // if an id is provided, cast to string.
      extendedObject[options.idProperty] = '' + extendedObject[options.idProperty]
    }
    data.push(extend({}, extendedObject))
    self.emit('afterCreate', extendedObject)
    callback(undefined, extendedObject)
  }
function create(object, callback) {
    self.emit('create', object)
    callback = callback || emptyFn
    // clone the object
    var extendedObject = extend({}, object)

    if (!extendedObject[options.idProperty]) {
      idSeq += 1
      extendedObject[options.idProperty] = '' + idSeq
    } else {
      if (findById(extendedObject[options.idProperty]) !== null) {
        return callback(new Error('Key ' + extendedObject[options.idProperty] + ' already exists'))
      }
      // if an id is provided, cast to string.
      extendedObject[options.idProperty] = '' + extendedObject[options.idProperty]
    }
    data.push(extend({}, extendedObject))
    self.emit('afterCreate', extendedObject)
    callback(undefined, extendedObject)
  }
function create ( object , callback ) { self . emit ( 'create' , object ) callback = callback || emptyFn // clone the object var extendedObject = extend ( { } , object ) if ( ! extendedObject [ options . idProperty ] ) { idSeq += 1 extendedObject [ options . idProperty ] = '' + idSeq } else { if ( findById ( extendedObject [ options . idProperty ] ) !== null ) { return callback ( new Error ( 'Key ' + extendedObject [ options . idProperty ] + ' already exists' ) ) } // if an id is provided, cast to string. extendedObject [ options . idProperty ] = '' + extendedObject [ options . idProperty ] } data . push ( extend ( { } , extendedObject ) ) self . emit ( 'afterCreate' , extendedObject ) callback ( undefined , extendedObject ) }
Create a new entity. Emits a 'create' event.

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