MCPcopy Create free account
hub / github.com/Automattic/mongoose / createModel

Function createModel

test/query.defaultSort.test.js:23–31  ·  view source on GitHub ↗
(defaultSort = { value: -1 })

Source from the content-addressed store, hash-verified

21 afterEach(() => require('./util').stopRemainingOps(db));
22
23 async function createModel(defaultSort = { value: -1 }) {
24 const Test = db.model('Test', new Schema({ name: String, value: Number }, { defaultSort }));
25 await Test.insertMany([
26 { name: 'a', value: 1 },
27 { name: 'b', value: 3 },
28 { name: 'c', value: 2 }
29 ]);
30 return Test;
31 }
32
33 it('throws on invalid `defaultSort` values when creating the schema', function() {
34 assert.throws(() => new Schema({}, { defaultSort: 42 }), /`defaultSort` must be falsy, string, object, array, or Map, got `number`/);

Callers 1

Calls 1

insertManyMethod · 0.65

Tested by

no test coverage detected