distinct

Collection.distinct(dbId, collectionName, columnName[, queryString][, token])

Queries a list of distinct values from a specified collections column.

Parameters

This function has the following parameters:

ArgumentDescriptionRequired
dbApiKeyString with database API key.Yes.
tokenString with user token or database Master key.No.
collectionNameString with database collection name.Yes.
columnNameString with database column name on which distinct operation will be invoked.Yes.
queryStringQuery to select particular objects on which to invoke the distinct operation. JSON query object that was built in accordance with the Mongo querying documentation.No.
Examples

This example will retrieve all distinct values from major column. Distinct will return only data from the specified column. In other words, other collection data (columns) are not returned. The Result tab shows information assuming the collection only has English and Chemistry as majors.

var dbApiKey = "c33010af-f263-4443-9897-c2ffaf522956";
result = Collection.distinct(dbApiKey, "Student", "major");
[
	{
		"name": "English"
	},
	{
		"name": "Chemistry"
	}
]
This example will retrieve distinct values from column named Size but only for values greater than 10:

var dbApiKey = "c33010af-f263-4443-9897-c2ffaf522956";
var result = Collection.distinct(dbApiKey, "Quantity", 'Size', {"Size":{"$gt":10}});
[
	20,
	100,
	50,
	120
]