CRUD Interface
CRUD Interface includes New, Get, Set, Mix,and Del. CRUD Interface is below the X method. therefore CRUD Interface must be used follow the X method. To manipulate, for instance, the Get of CRUD interface for a X method is as follow:
New()
If the collection does not currently exist, insert operations will create the collection.
Create data and insert Documents. 'New' method must include an argument of JSON object. The following example inserts a new document into the test collection.
If the documents do not specify an _id field, X-Server adds the _id field with an ObjectId value to each document.
More fields:
_id Field
In X-Server, each document stored in a collection requires a unique _id field that acts as a primary key. If an inserted document omits the _id field, the X-Server automatically generates an ObjectId for the _id field.
Get()
Read and query data. The returned result contains the following four objects:
sum, is the total number of records in the database.
data, is a array of returned records.
go, is the index of current record.
max, is the maximum number of returned records.
ID()
ID() is an overloaded function of Get().
ID(id) = Get{_id:id}
So just return the data of the id.
Set()
Update data.
Mix()
Merge data, instead of Put.
Del()
To delete all documents from a collection, pass an empty filter document {} to the Del() method. The following example deletes all documents from the test collection:
Delete All Documents that Match a Condition You can specify criteria, or filters, that identify the documents to delete. The filters use the same syntax as read operations.
To specify equality conditions, use : expressions in the query filter document:
A query filter document can use the query operators to specify conditions in the following form:
To delete all documents that match a deletion criteria, pass a filter parameter to the Del() method.
The following example removes all documents from the inventory collection where the status field equals "A":
Last updated