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

Method sync

lib/database.ts:196–212  ·  view source on GitHub ↗

Create the given models in the current database. * * await db.sync({ drop: true });

(options: SyncOptions = {})

Source from the content-addressed store, hash-verified

194 * await db.sync({ drop: true });
195 */
196 async sync(options: SyncOptions = {}) {
197 if (options.drop) {
198 for (let i = this._models.length - 1; i >= 0; i--) {
199 await this._models[i].drop();
200 }
201 }
202
203 if (options.truncate) {
204 for (let i = this._models.length - 1; i >= 0; i--) {
205 await this._models[i].truncate();
206 }
207 }
208
209 for (const model of this._models) {
210 await model.createTable();
211 }
212 }
213
214 /** Associate all the required information for a model to connect to a database.
215 *

Callers 6

update.test.tsFile · 0.80
update.test.tsFile · 0.80
insert.test.tsFile · 0.80
response.test.tsFile · 0.80
models.test.tsFile · 0.80
foreignkey.test.tsFile · 0.80

Calls 3

dropMethod · 0.80
truncateMethod · 0.45
createTableMethod · 0.45

Tested by

no test coverage detected