MCPcopy
hub / github.com/Automattic/mongoose / createWithSubdocs

Function createWithSubdocs

test/types/create.test.ts:174–188  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

172}
173
174async function createWithSubdocs() {
175 const schema = new Schema({
176 name: String,
177 subdoc: new Schema({
178 prop: { type: String, required: true },
179 otherProp: { type: String, required: true }
180 })
181 });
182 const TestModel = model('Test', schema);
183
184 const doc = await TestModel.create({ name: 'test', subdoc: { prop: 'test 1' } });
185 expect(doc.name).type.toBe<string | null | undefined>();
186 expect(doc.subdoc!.prop).type.toBe<string>();
187 expect(doc.subdoc!.otherProp).type.toBe<string>();
188}
189
190async function createWithRawDocTypeNo_id() {
191 interface RawDocType {

Callers

nothing calls this directly

Calls 2

modelFunction · 0.85
createMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…