find(query, return_obj, user_id, callback)
query
is a js-obejct that contains the contrains on the data requested.return_obj
is a js-object specificaion of which data is requested, in respect to "the data schema"user_id
is just the users id and is used to query only the data that is within the users righscallback
is a javaScript function that will be call when the data is ready.
The query is build as "the data schema", such that each can be constrained using the grammar described in the end of the document
upload: {
id: "12314123214142414",
upload_date: "$lt 123412431421",
runs: {
groups: {
results: {
name: "/LTE/",
}
}
}
}
The return_obj
is an object that specifies which data is wanted in the response of the request. If a property is set to 1 it means that the property should be in the returned object, likewise if a property is set to 0 it means that it should be left out.
** Note:** You cannot mix 0's and 1's in a single object. This is done as, all non-mentioned proerties will have the negated value as those inclued.
The return_obj
must follow the "the data schema".
{
upload: {
id: 1,
upload_date: 1,
number_of_runs: 1
runs: {
id: 1
}
}
This will return a lift of uploads where each of them has the id
, upload_date
, number_of_runs
and a list of runs where each of them just have their id
.
{
upload: {
upload_date: 0,
number_of_runs: 0
runs: 0
}
This will return a list of uploads each with an id
. Assuming that id
, upload_date
, number_of_runs
, and runs
are the only members of upload
in the database.
user_id
is used to ensure that the user cannot access data outside its scope.
callback
is a javaScript function with signature: function (returned_objects, err)
where
returned_objects
is an array of obejcts found based on thequery
and populated as perreturn_obj
.err
is an error obejct containg a proper error message.
update(query, update, user_id, callback)
query
is a js-obejct that contains the contrains on which data should be updated.update
is a js-object that contains the actual updates.user_id
is just the users id and is used to ensure that only data that is within the users righs is updated.callback
is a javaScript function that will be call when the the udpdate is done.
The query is build as "the data schema", such that each can be constrained using the grammar described in the end of the document
{
upload: {
id: "12314123214142414",
runs: {
groups: {
results: {
id: "1112314124412412124",
}
}
}
}
}
The update
parameter is an object folliwn "the data scheme" such that for each mentioned parameter an "update query" is given using the mongoDB syntax.
{
upload: {
runs: {
groups: {
results: {
result_name: "new name"
}
}
}
}
}
user_id
is used to ensure that the user cannot update] data outside its scope.
callback
is a javaScript function with signature: function (err)
where
err
is an error obejct containg a proper error message.
remove(query,user_id,callback)
query
is a js-obejct that contains the contrains on which data should be updated.user_id
is just the users id and is used to ensure that only data that is within the users righs is updated.callback
is a javaScript function that will be call when the the udpdate is done.
The query is build as "the data schema", such that each can be constrained using the grammar described in the end of the document. Note: All mebers of the queried object will be removed aswell.
{
upload: {
id: "12314123214142414",
}
}
With this query all runs,groups and results of this particular upload will be deleted.
user_id
is used to ensure that the user cannot update] data outside its scope.
callback
is a javaScript function with signature: function (err)
where
err
is an error obejct containg a proper error message.
query ::= clause | regEx
clause ::= part | (clause) boolOp (clause) | $not (clause)
part ::= compOp num | listOp list | num
boolOp ::= $or | $and | $nor
compOp ::= $lt | $lte | $gt | $gte | $ne
listOp ::= $in | $nin
regEx ::= /some regExp string/
num ::= parseFloat()
list ::= [some list]
($gt 14.2) $or ($lte 11.9)
($in:[1,2,4,6]) $nor (($in:[11,13,14,15]) $and ($in[111,113,114]))
/[0-9]+ LTE/
12.4