putByIndex method

  1. @experimental
Future<Id> putByIndex(
  1. String indexName,
  2. OBJ object
)

Insert or update the object by the unique index indexName. Returns the id of the new or updated object.

If there is already an object with the same index key, it will be updated and all links will be preserved. Otherwise a new object will be inserted.

If the object has an non-final id property, it will be set to the assigned id. Otherwise you should use the returned id to update the object.

If possible, you should use the generated type-safe methods instead.

Implementation

@experimental
Future<Id> putByIndex(String indexName, OBJ object) {
  return putAllByIndex(indexName, [object]).then((List<Id> ids) => ids[0]);
}