Simple DocumentDb stored procedure -



Simple DocumentDb stored procedure -

i'm trying create simple documentdb stored procedure improve understand concepts. in example, i'm trying homecoming "female" users. need concern myself returning single matching document or multiple documents?

here's user object looks like:

{ "id": "e85ee3d7-44a5-4250-a116-686e1c2a10f5" "firstname": "jane", "lastname": "doe", "gender": "f" }

and here's storedproc looks far:

function(gender) { var context = getcontext(); var response = context.getresponse(); var collection = context.getcollection(); var collectionlink = collection.getselflink(); var filterquery = "select * c c.gender = '" + gender + "'"; // what??? }

i'd homecoming female users. there may 1 or 10,000 female users.

i'd appreciate help simple documentdb stored procedure. thanks.

you're on right track.

the next steps run filterquery on collection, , place query response in response variable.

for example:

function(gender) { var context = getcontext(); var response = context.getresponse(); var collection = context.getcollection(); var collectionlink = collection.getselflink(); var filterquery = 'select * c c.gender = "' + gender + '"'; collection.querydocuments(collectionlink, filterquery, {}, function(err, documents) { response.setbody(response.getbody() + json.stringify(documents)); } ); }

you can find more samples , documentation on stored procedures on documentdb's website: http://azure.microsoft.com/en-us/documentation/articles/documentdb-programming/

azure-documentdb

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -