Extension::MongoDBGetRecords Method
Syntax
.GetRecords as c (criteria as C [, sorting as C [, view as C]])
Arguments
- criteria
Optional JSON representation of the fields to match
- sorting
Optional JSON representation of the fields to sort on
- view
Optional JSON of the columns to exclude from the search.
Description
Get records from mongo collection that match the criteria spec.
dim mongo as extension::MongoDB = extension::MongoDB::Create("mongodb://localhost:27017","Northwinds","Customers")
dim json as c = mongo.GetRecords("{ \"Country\" : \"USA\" }","{ \"City\" : 1 }","{ \"_id\" : 0 ,\"ContactTitle\" : 0 , \"ContactName\" : 0 , \"Address\" : 0 , \"PostalCode\" : 0 , \"Phone\" : 0 , \"Fax\" : 0}")
? json_reformat(json)
= [
{
"CustomerID": "RATTC",
"CompanyName": "Rattlesnake Canyon Grocery",
"City": "Albuquerque",
"Region": "NM",
"Country": "USA"
},
{
"CustomerID": "OLDWO",
"CompanyName": "Old World Delicatessen",
"City": "Anchorage",
"Region": "AK",
"Country": "USA"
},
{
"CustomerID": "SAVEA",
"CompanyName": "Save-a-lot Markets",
"City": "Boise",
"Region": "ID",
"Country": "USA"
},
....This example shows using all the parameters to select Customers from the Country'USA', sorted ascending on the City column, filtering out _id, ContactTitle, ContactName, Address , PostalCode , Phone and Fax columns from the returned view.