Adds an object to the object store.

Syntax

table.add(item, [key])

Parameters

itemObject to add
keyPrimary keyoptional

Return Value

Promise

Remarks

Add given object to store. If an object with the same primary key already exist, the operation will fail and returned promise catch() callback will be called with the error object. If the operation succeeds, the returned promise then() callback receives the result of the add request on the object store, the id of the inserted object.

The optional second key argument must only be used if your table uses outbound keys. If providing the key argument on a table with inbound keys, the operation will fail and the returned promise will be a rejection.

See Also

Table.put()

Table of Contents