MCPcopy
hub / github.com/mongodb/node-mongodb-native / cursorSort

Function cursorSort

test/integration/crud/misc_cursors.test.ts:1656–1672  ·  view source on GitHub ↗
(input, output)

Source from the content-addressed store, hash-verified

1654 };
1655
1656 const cursorSort = (input, output) =>
1657 async function () {
1658 const client = this.configuration.newClient({ monitorCommands: true });
1659 const events = [];
1660 client.on('commandStarted', event => {
1661 if (event.commandName === 'find') {
1662 events.push(event);
1663 }
1664 });
1665 const db = client.db('test');
1666 const collection = db.collection('test_sort_dos');
1667 const cursor = collection.find({}).sort(input);
1668 await cursor.next();
1669 expect(events[0].command.sort).to.be.instanceOf(Map);
1670 expect(Array.from(events[0].command.sort)).to.deep.equal(Array.from(output));
1671 await client.close();
1672 };
1673
1674 it('should use find options object', findSort({ alpha: 1 }, new Map([['alpha', 1]])));
1675 it('should use find options string', findSort('alpha', new Map([['alpha', 1]])));

Callers 1

Calls 9

onMethod · 0.80
collectionMethod · 0.65
newClientMethod · 0.45
pushMethod · 0.45
dbMethod · 0.45
sortMethod · 0.45
findMethod · 0.45
nextMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected