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. Triggers add even if new object created

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