MCPcopy
hub / github.com/eveningkid/denodb / create

Method create

lib/model.ts:446–462  ·  view source on GitHub ↗
(values: Values | Values[])

Source from the content-addressed store, hash-verified

444 static async create(values: Values): Promise<Model>;
445 static async create(values: Values[]): Promise<Model[]>;
446 static async create(values: Values | Values[]) {
447 const insertions = Array.isArray(values) ? values : [values];
448
449 const results = await this._runQuery(
450 this._currentQuery.table(this.table).create(
451 insertions.map((field) =>
452 this.formatFieldToDatabase(this._wrapValuesWithDefaults(field))
453 ) as Values[],
454 ).toDescription(),
455 );
456
457 if (!Array.isArray(values) && Array.isArray(results)) {
458 return results[0];
459 }
460
461 return results;
462 }
463
464 /** Find one or multiple records based on the model primary key.
465 *

Callers 7

saveMethod · 0.45
update.test.tsFile · 0.45
update.test.tsFile · 0.45
insert.test.tsFile · 0.45
response.test.tsFile · 0.45
models.test.tsFile · 0.45
foreignkey.test.tsFile · 0.45

Calls 5

_runQueryMethod · 0.95
formatFieldToDatabaseMethod · 0.95
toDescriptionMethod · 0.80
tableMethod · 0.80

Tested by

no test coverage detected