Skip to content

Sleepy Mongoose calls

colinmccann edited this page Nov 3, 2011 · 9 revisions

We have set up sleepy mongoose and it is reachable on proto:

http://proto.encorelab.org/mongoose/

The database is called wallcology and the dataset (?) observations. The following URL will find everything withing observations: http://proto.encorelab.org/mongoose/wallcology/observations/_find

The following REST call will query for objects in observations that have a key: type value: relationship {"type":"relationship"} where %22 is " and %3A is : http://proto.encorelab.org/mongoose/wallcology/observations/_find?criteria={%22type%22%3A%22relationship%22}

To query for more than on criteria and one that is a level deeper: key: type / value: relationship key: energy_transfer.to / value: green-bug http://proto.encorelab.org/mongoose/wallcology/observations/_find?criteria={%22type%22%3A%22relationship%22,%20%22energy_transfer.from%22%3A%22blue-bug%22,%20%22energy_transfer.to%22%3A%22green-bug%22}

And now use the result by energy_transfer.to ascending: http://proto.encorelab.org/mongoose/wallcology/observations/_find?criteria={%22type%22%3A%22relationship%22}&sort={%22energy_transfer.to%22:1}

descending: http://proto.encorelab.org/mongoose/wallcology/observations/_find?criteria={%22type%22%3A%22relationship%22}&sort={%22energy_transfer.to%22%3A-1}

Thanks to Matt our Sleepy Mongoose can now do counting for us. This counts all objects in observations: http://proto.encorelab.org/mongoose/wallcology/observations/_count

And this counts all objects in observations that have "type":"relationship" http://proto.encorelab.org/mongoose/wallcology/observations/_count?criteria={%22type%22%3A%22relationship%22}

And 'batch_size' overrides the standard upper query limit of 15 ie $.get("/mongoose/wallcology/observations/_find", { batch_size: 100, criteria:{"type":"relationship"} },

To set the batch size in the command line: DBQuery.shellBatchSize = 100

Now I want to count all elements with: "type":"relationship" "energy_transfer.from":"blue-bug" "energy_transfer.to":"green-bug" http://proto.encorelab.org/mongoose/wallcology/observations/_count?criteria={%22type%22%3A%22relationship%22,%20%22energy_transfer.from%22%3A%22blue-bug%22,%20%22energy_transfer.to%22%3A%22green-bug%22}

I want to select, sort and ensure I get more than 15 results http://proto.encorelab.org/mongoose/wallcology/observations/_find?criteria={%22type%22%3A%22organism%22}&sort={%22organism%22%3A-1}&batch_size=100

Clone this wiki locally