findOrAdd

function
 findOrAdd() 

Option name Type Description
idOrObject String, Object

id or object with .id property

[properties] Object

Optional properties if id passed as first option

return Promise

tries to find object in local database, otherwise creates new one
with passed properties.

function findOrAdd (idOrObjectOrArray, newObject) {
  return Array.isArray(idOrObjectOrArray)
    ? findOrAddMany.call(this, null, idOrObjectOrArray)
    : findOrAddOne.call(this, null, idOrObjectOrArray, newObject)
}