set method

Future<APIResponse<Map<String, dynamic>>> set(
  1. Map<String, dynamic> values,
  2. String parentId, [
  3. SetOptions? options
])

Sets the object field value of a parent object identified by parentId. This method is valid only for sub-model objects, objects with a parent. If this method is called for a top-level model object or sub-model object-list, an error will be returned.

If the id is provided as input to this DBObject, its value will be ignored by this method since Altogic will automatically assign an id for new objects created in the database.

If the client library key is set to enforce session, an active user session is required (e.g., user needs to be logged in) to call this method.

values An object that contains the fields and their values to create in the database.

parentId the id of the parent object.

options Create operation options. By default no caching of the newly created object in Redis store and no top level object return.

Returns the newly create object in the database.

Implementation

Future<APIResponse<Map<String, dynamic>>> set(
        Map<String, dynamic> values, String parentId,
        [SetOptions? options]) =>
    _fetcher.post<Map<String, dynamic>>('/_api/rest/v1/db/object/set', body: {
      'values': values,
      'options': DEFAULT_SET_OPTIONS.merge(options).toJson(),
      'model': _modelName,
      'id': _id,
      'parentId': parentId
    });