Collection creation:
db.createCollection("myColl", {collation: {...}});
Index creation:
db.coll.ensureIndex({key: 1, pattern: 1}, {collation: {...}}); db.coll.createIndex({key: 1, pattern: 1}, {collation: {...}}); db.coll.createIndexes([{key: 1}, {pattern: 1}], {collation: {...}});
Operations:
db.coll.find().collation({...}); db.coll.find().collation({...}).count(); db.coll.aggregate([..], {collation: {...}}); db.coll.distinct(<key>, <predicate>, {collation: {...}}); db.coll.findAndModify({<update|remove>: ..., collation: {...}); db.coll.group({ key: ..., reduce: ..., initial: ..., collation: {...} }); db.coll.mapReduce(<map>, <reduce>, {collation: {...}}); db.coll.remove(<predicate>, {collation: {...}}); db.coll.update(<predicate>, <mods>, {collation: {...}});
(Note that geoNear is omitted because it does not have a shell helper.)
CRUD API:
db.coll.bulkWrite([ {updateOne: {..., collation: {...}}}, {updateMany: {..., collation: {...}}}, {replaceOne: {..., collation: {...}}}, {deleteOne: {..., collation: {...}}}, {deleteMany: {..., collation: {...}}} ]); db.coll.deleteOne(<filter>, {collation: {...}}); db.coll.deleteMany(<filter>, {collation: {...}}); db.coll.findOneAndDelete(<filter>, {collation: {...}}); db.coll.findOneAndReplace( <filter>, <replacement>, {collation: {...}} ); db.coll.findOneAndUpdate( <filter>, <update>, {collation: {...}} ); db.coll.replaceOne(<filter>, <replacement>, {collation: {...}}); db.coll.updateOne(<filter>, <update>, {collation: {...}}); db.coll.updateMany(<filter>, <update>, {collation: {...}});
Bulk write API:
var bulk = db.coll.initializeUnorderedBulkOp();
bulk.find({...}).collation({...});
bulk.execute();