MongoLink`
MongoLink`

MongoCollectionDistinct

MongoCollectionDistinct[MongoCollection[],f]

obtain a list of distinct values for the field in the collection.

MongoCollectionDistinct[MongoCollection[],field,query]

obtain a list of distinct values for the field for documents matching query.

Details

Examples

Basic Examples  (1)

In[1]:=
Click for copyable input

Connect to a client:

In[1]:=
Click for copyable input
Out[1]=

Connect to a new "WolframTestDistinct" collection in the "WolframTestDB" database:

In[1]:=
Click for copyable input
Out[1]=
In[1]:=
Click for copyable input
Out[1]=
In[1]:=
Click for copyable input
Out[1]=

Find the list of distinct items in the "dept" field:

In[1]:=
Click for copyable input
Out[1]=

Find the list of distinct items in the "sku" subfield of the "item" field:

In[1]:=
Click for copyable input
Out[1]=

Find the list of distinct items in the "sku" subfield of the "item" field from the set of documents whose "dept" field has value "A":

In[1]:=
Click for copyable input
Out[1]=

Destroy the collection that was created:

In[1]:=
Click for copyable input

See Also

MongoCollection  MongoCollectionStats

Tutorials