Xenioo Database Collection Methods
The Connect connection object represent a connection instance to your chatbot database. The following methods are exposed by the connection object to interact with your data.
Connect
Returns a virtual Connect database instance that can be further used to manipulate remote data.
Save
This method will insert or update a record in the specified collection. The collection must first be created in the Database Collections interface. Objects should be supplied as standard JS objects.
If the object contains an _id field, Connect will attempto to update the record, overwriting it.
The following example will save a new record inside the users collection:
Update
This method will update a record in the specified collection. The collection must first be created in the Database Collections interface. Objects should be supplied as standard JS objects.
This method will use all of the fields of the supplied object ot update the target record. If the field does not exist in the target record, it will be created.
Update mode can be one of the following values:
The following example will update a field for a user in the example users collection:
Delete
Deletes one or more records from a collection, using the specified filters.
If filter contains a record unique id, only that specific record will be deleted. If filter contains instead a supported URL Filter it will delete all the affected records.
The following example deletes a single record from the example users collection:
The following example instead will delete all users who are not enabled from the example users collection:
Load
This method will load a single record from a collection
If filter contains a record unique id, only that specific record will be loaded. If filter contains instead a supported URL Filter the first record that matches the filter will be returned
Query
This method will open a cursor pointing to a list of all the objects that are currently stored in the specified collection that matches the given filter
Filter can contain a valid URL Filter or be empty. An empty filter will return a cursor pointing to all records in the collection.
This method does not return any actual data. It must be used together with a loop with Read.
Read
This method will read the next available record in the current cursor opened with Query.
In the following example, our cloud script will loop on all records inside the users collection that are not enabled:
Last updated