create method
- Map<
String, dynamic> values, [ - CreateOptions? options
Creates a top level model object in the database. This method is valid only for top-level models, models without a parent. If this method is called for a sub-model object or 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.
options
Create operation options. By default no caching of the newly
created object in Redis store.
Returns the newly create object in the database.
Implementation
Future<APIResponse<Map<String, dynamic>>> create(Map<String, dynamic> values,
[CreateOptions? options]) =>
_fetcher
.post<Map<String, dynamic>>('/_api/rest/v1/db/object/create', body: {
'values': values,
'options': DEFAULT_CREATE_OPTIONS.merge(options).toJson(),
'model': _modelName
});