MCPcopy Create free account
hub / github.com/Kong/insomnia / flushChangesImpl

Function flushChangesImpl

packages/insomnia-data/node-src/database/database-nedb.ts:91–116  ·  view source on GitHub ↗
(id = 0, fake = false)

Source from the content-addressed store, hash-verified

89
90 /** trigger all changeListeners */
91 const flushChangesImpl: FlushChangesImpl = async function (id = 0, fake = false) {
92 // Only flush if ID is 0 or the current flush ID is the same as passed
93 if (id !== 0 && bufferChangesId !== id) {
94 return;
95 }
96
97 bufferingChanges = false;
98 const changes = [...changeBuffer];
99 changeBuffer = [];
100
101 if (changes.length === 0) {
102 // No work to do
103 return;
104 }
105
106 if (fake) {
107 console.log(`[db] Dropped ${changes.length} changes.`);
108 return;
109 }
110 // Notify local listeners too
111 for (const fn of changeListeners) {
112 await fn(changes);
113 }
114
115 return changes;
116 };
117
118 const originalDatabase: IDatabase<initOptions> = {
119 batchModifyDocs: async function ({ upsert = [], remove = [] }: Operation) {

Callers 1

createNedbDatabaseFunction · 0.85

Calls 2

fnFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected