DBObject class

References an object stored in a specific model of your application. It provides the methods to get, update, delete an existing object identified by its id or create, set or append a new object.

If id is provided when creating an instance, you can use get, update, delete and updateFields methods.

If no id specified in constructor, you can use create, set, and append methods to create a new object in the database.

create method is used to creat a top-level object, which does not have any parent. set method is used to set the value of an object field of a parent object and finally append is used to add a child object to an object-list field of a parent object.

Since both set and append operate on a sub-model or sub-model list object respectively, you need to pass a parentId as an input parameter.

Inheritance

Constructors

DBObject(String modelName, Fetcher fetcher, String? id)
Creates an instance of DBObject

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

append(Map<String, dynamic> values, String parentId, [AppendOptions? options]) Future<APIResponse<Map<String, dynamic>>>
Appends the input object to the object list field of a parent object identified by parentId. This method is valid only for sub-model object-lists, object-lists with a parent. If this method is called for a top-level model object or sub-model object, an error will be returned.
create(Map<String, dynamic> values, [CreateOptions? options]) Future<APIResponse<Map<String, dynamic>>>
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.
delete([DeleteOptions? options]) Future<APIResponse<Map<String, dynamic>>>
Deletes the document referred to by this DBObject and identified by the id. For a top level model object this method deletes the object from the database and for sub-model objects either unsets its value or removes it from its parent's object list. If the id of the db object is not defined, it returns an error.
get({List<Lookup>? lookups, GetOptions? options}) Future<APIResponse<Map<String, dynamic>>>
Gets the object referred to by this db object and identified by the id from the database. While getting the object it also performs the specified lookups. If the id of the db object is not specified, it returns an error.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(Map<String, dynamic> values, String parentId, [SetOptions? options]) Future<APIResponse<Map<String, dynamic>>>
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.
toString() String
A string representation of this object.
inherited
update(Map<String, dynamic> values, [UpdateOptions? options]) Future<APIResponse<Map<String, dynamic>>>
Updates the object referred to by this db object and identified by the id using the input values. This method directly sets the field values of the object in the database with the values provided in the input.
updateFields(dynamic fieldUpdates, [UpdateOptions? options]) Future<APIResponse<Map<String, dynamic>>>
Updates the fields of object referred to by this db object and identified by the id using the input FieldUpdate instruction(s).

Operators

operator ==(Object other) bool
The equality operator.
inherited