@delma/fylo 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +185 -267
  2. package/package.json +2 -5
  3. package/src/core/directory.ts +22 -354
  4. package/src/engines/s3-files/documents.ts +65 -0
  5. package/src/engines/s3-files/filesystem.ts +172 -0
  6. package/src/engines/s3-files/query.ts +291 -0
  7. package/src/engines/s3-files/types.ts +42 -0
  8. package/src/engines/s3-files.ts +391 -690
  9. package/src/engines/types.ts +1 -1
  10. package/src/index.ts +142 -1237
  11. package/src/sync.ts +58 -0
  12. package/src/types/fylo.d.ts +66 -161
  13. package/src/types/node-runtime.d.ts +1 -0
  14. package/tests/collection/truncate.test.js +11 -10
  15. package/tests/helpers/root.js +7 -0
  16. package/tests/integration/create.test.js +9 -9
  17. package/tests/integration/delete.test.js +16 -14
  18. package/tests/integration/edge-cases.test.js +29 -25
  19. package/tests/integration/encryption.test.js +47 -30
  20. package/tests/integration/export.test.js +11 -11
  21. package/tests/integration/join-modes.test.js +16 -16
  22. package/tests/integration/nested.test.js +26 -24
  23. package/tests/integration/operators.test.js +43 -29
  24. package/tests/integration/read.test.js +25 -21
  25. package/tests/integration/rollback.test.js +21 -51
  26. package/tests/integration/s3-files.performance.test.js +75 -0
  27. package/tests/integration/s3-files.test.js +57 -44
  28. package/tests/integration/sync.test.js +154 -0
  29. package/tests/integration/update.test.js +24 -18
  30. package/src/adapters/redis.ts +0 -487
  31. package/src/adapters/s3.ts +0 -61
  32. package/src/core/walker.ts +0 -174
  33. package/src/core/write-queue.ts +0 -59
  34. package/src/migrate-cli.ts +0 -22
  35. package/src/migrate.ts +0 -74
  36. package/src/types/write-queue.ts +0 -42
  37. package/src/worker.ts +0 -18
  38. package/src/workers/write-worker.ts +0 -120
  39. package/tests/index.js +0 -14
  40. package/tests/integration/migration.test.js +0 -38
  41. package/tests/integration/queue.test.js +0 -83
  42. package/tests/mocks/redis.js +0 -123
  43. package/tests/mocks/s3.js +0 -80
package/src/sync.ts ADDED
@@ -0,0 +1,58 @@
1
+ export type FyloSyncMode = 'await-sync' | 'fire-and-forget'
2
+
3
+ export interface FyloWriteSyncEvent<T extends Record<string, any> = Record<string, any>> {
4
+ operation: 'put' | 'patch'
5
+ collection: string
6
+ docId: _ttid
7
+ previousDocId?: _ttid
8
+ path: string
9
+ data: T
10
+ }
11
+
12
+ export interface FyloDeleteSyncEvent {
13
+ operation: 'delete' | 'patch'
14
+ collection: string
15
+ docId: _ttid
16
+ path: string
17
+ }
18
+
19
+ export interface FyloSyncHooks<T extends Record<string, any> = Record<string, any>> {
20
+ onWrite?: (event: FyloWriteSyncEvent<T>) => Promise<void> | void
21
+ onDelete?: (event: FyloDeleteSyncEvent) => Promise<void> | void
22
+ }
23
+
24
+ export interface FyloOptions<T extends Record<string, any> = Record<string, any>> {
25
+ root?: string
26
+ s3FilesRoot?: string
27
+ sync?: FyloSyncHooks<T>
28
+ syncMode?: FyloSyncMode
29
+ }
30
+
31
+ export class FyloSyncError extends Error {
32
+ readonly collection: string
33
+ readonly docId: _ttid
34
+ readonly path: string
35
+ readonly operation: string
36
+
37
+ constructor(args: {
38
+ collection: string
39
+ docId: _ttid
40
+ path: string
41
+ operation: string
42
+ cause: unknown
43
+ }) {
44
+ super(
45
+ `FYLO sync failed after the local filesystem operation succeeded for ${args.operation} ${args.collection}/${args.docId}. Local state is already committed at ${args.path}.`,
46
+ { cause: args.cause }
47
+ )
48
+ this.name = 'FyloSyncError'
49
+ this.collection = args.collection
50
+ this.docId = args.docId
51
+ this.path = args.path
52
+ this.operation = args.operation
53
+ }
54
+ }
55
+
56
+ export function resolveSyncMode(syncMode?: FyloSyncMode): FyloSyncMode {
57
+ return syncMode ?? 'await-sync'
58
+ }
@@ -10,16 +10,14 @@ interface _findDocs {
10
10
  void,
11
11
  unknown
12
12
  >
13
- once<T>(): Promise<Record<_ttid, T>>
13
+ collect<T>(): AsyncGenerator<
14
+ _ttid | Record<_ttid, T> | Record<string, _ttid[]> | Record<_ttid, Partial<T>> | undefined,
15
+ void,
16
+ unknown
17
+ >
14
18
  onDelete(): AsyncGenerator<_ttid, void, unknown>
15
19
  }
16
20
 
17
- interface _queuedWriteResult {
18
- jobId: string
19
- docId: _ttid
20
- status: 'queued' | 'processing' | 'committed' | 'failed' | 'dead-letter'
21
- }
22
-
23
21
  interface ObjectConstructor {
24
22
  appendGroup: (target: Record<string, any>, source: Record<string, any>) => Record<string, any>
25
23
  }
@@ -34,20 +32,58 @@ type _joinDocs<T, U> =
34
32
  | Record<string, Record<_ttid, Partial<T | U>>>
35
33
  | Record<`${_ttid}, ${_ttid}`, T | U | (T & U) | (Partial<T> & Partial<U>)>
36
34
 
37
- type _fyloEngineKind = 'legacy-s3' | 's3-files'
35
+ type _fyloSyncMode = 'await-sync' | 'fire-and-forget'
36
+
37
+ interface _fyloWriteSyncEvent<T extends Record<string, any> = Record<string, any>> {
38
+ operation: 'put' | 'patch'
39
+ collection: string
40
+ docId: _ttid
41
+ previousDocId?: _ttid
42
+ path: string
43
+ data: T
44
+ }
45
+
46
+ interface _fyloDeleteSyncEvent {
47
+ operation: 'delete' | 'patch'
48
+ collection: string
49
+ docId: _ttid
50
+ path: string
51
+ }
52
+
53
+ interface _fyloSyncHooks<T extends Record<string, any> = Record<string, any>> {
54
+ onWrite?: (event: _fyloWriteSyncEvent<T>) => Promise<void> | void
55
+ onDelete?: (event: _fyloDeleteSyncEvent) => Promise<void> | void
56
+ }
38
57
 
39
58
  interface _fyloOptions {
40
- engine?: _fyloEngineKind
59
+ root?: string
41
60
  s3FilesRoot?: string
61
+ sync?: _fyloSyncHooks
62
+ syncMode?: _fyloSyncMode
42
63
  }
43
64
 
44
65
  declare module '@delma/fylo' {
66
+ export class FyloSyncError extends Error {
67
+ readonly collection: string
68
+ readonly docId: _ttid
69
+ readonly path: string
70
+ readonly operation: string
71
+ }
72
+
73
+ export type FyloSyncMode = _fyloSyncMode
74
+ export type FyloWriteSyncEvent<T extends Record<string, any> = Record<string, any>> =
75
+ _fyloWriteSyncEvent<T>
76
+ export type FyloDeleteSyncEvent = _fyloDeleteSyncEvent
77
+ export type FyloSyncHooks<T extends Record<string, any> = Record<string, any>> =
78
+ _fyloSyncHooks<T>
79
+ export type FyloOptions = _fyloOptions
80
+
45
81
  export default class {
46
82
  constructor(options?: _fyloOptions)
47
83
 
48
84
  /**
49
- * Rolls back all transcations in current instance
50
- * @deprecated Prefer queued write recovery, dead letters, or compensating writes.
85
+ * Compatibility helper. FYLO now writes synchronously to the filesystem,
86
+ * so rollback is a no-op.
51
87
  */
52
88
  rollback(): Promise<void>
53
89
 
@@ -60,202 +96,71 @@ declare module '@delma/fylo' {
60
96
  SQL: string
61
97
  ): Promise<number | void | any[] | _ttid | Record<any, any>>
62
98
 
63
- /**
64
- * Creates a new schema for a collection.
65
- * @param collection The name of the collection.
66
- */
67
99
  static createCollection(collection: string): Promise<void>
68
-
69
- /**
70
- * Drops an existing schema for a collection.
71
- * @param collection The name of the collection.
72
- */
73
100
  static dropCollection(collection: string): Promise<void>
74
101
 
75
- /**
76
- * Imports data from a URL into a collection.
77
- * @param collection The name of the collection.
78
- * @param url The URL of the data to import.
79
- * @param limit The maximum number of documents to import.
80
- */
102
+ createCollection(collection: string): Promise<void>
103
+ dropCollection(collection: string): Promise<void>
104
+
81
105
  importBulkData(collection: string, url: URL, limit?: number): Promise<number>
82
106
 
83
- /**
84
- * Exports data from a collection to a URL.
85
- * @param collection The name of the collection.
86
- * @returns The current data exported from the collection.
87
- */
88
107
  exportBulkData<T extends Record<string, any>>(
89
108
  collection: string
90
109
  ): AsyncGenerator<T, void, unknown>
91
110
 
92
- /**
93
- * Gets a document from a collection.
94
- * @param collection The name of the collection.
95
- * @param _id The ID of the document.
96
- * @param onlyId Whether to only return the ID of the document.
97
- * @returns The document or the ID of the document.
98
- */
99
- static getDoc(collection: string, _id: _ttid, onlyId: boolean): _getDoc
111
+ static exportBulkData<T extends Record<string, any>>(
112
+ collection: string
113
+ ): AsyncGenerator<T, void, unknown>
114
+
115
+ static getDoc(collection: string, _id: _ttid, onlyId?: boolean): _getDoc
116
+
117
+ getDoc(collection: string, _id: _ttid, onlyId?: boolean): _getDoc
100
118
 
101
- /**
102
- * Puts multiple documents into a collection.
103
- * @param collection The name of the collection.
104
- * @param batch The documents to put.
105
- * @returns The IDs of the documents.
106
- */
107
119
  batchPutData<T extends Record<string, any>>(
108
120
  collection: string,
109
121
  batch: Array<T>
110
122
  ): Promise<_ttid[]>
111
123
 
112
- queuePutData<T extends Record<string, any>>(
113
- collection: string,
114
- data: Record<_ttid, T> | T
115
- ): Promise<_queuedWriteResult>
116
-
117
- queuePatchDoc<T extends Record<string, any>>(
118
- collection: string,
119
- newDoc: Record<_ttid, Partial<T>>,
120
- oldDoc?: Record<_ttid, T>
121
- ): Promise<_queuedWriteResult>
122
-
123
- queueDelDoc(collection: string, _id: _ttid): Promise<_queuedWriteResult>
124
-
125
- getJobStatus(jobId: string): Promise<Record<string, any> | null>
126
-
127
- getDocStatus(collection: string, docId: _ttid): Promise<Record<string, any> | null>
128
-
129
- getDeadLetters(count?: number): Promise<Array<Record<string, any>>>
130
-
131
- getQueueStats(): Promise<{ queued: number; pending: number; deadLetters: number }>
132
-
133
- replayDeadLetter(streamId: string): Promise<Record<string, any> | null>
134
-
135
- processQueuedWrites(count?: number, recover?: boolean): Promise<number>
136
-
137
- /**
138
- * Puts a document into a collection.
139
- * @param collection The name of the collection.
140
- * @param data The document to put.
141
- * @returns The ID of the document.
142
- */
143
124
  putData<T extends Record<string, any>>(collection: string, data: T): Promise<_ttid>
144
125
  putData<T extends Record<string, any>>(
145
126
  collection: string,
146
127
  data: Record<_ttid, T>
147
128
  ): Promise<_ttid>
148
- putData<T extends Record<string, any>>(
149
- collection: string,
150
- data: T,
151
- options: { wait?: true; timeoutMs?: number }
152
- ): Promise<_ttid>
153
- putData<T extends Record<string, any>>(
154
- collection: string,
155
- data: Record<_ttid, T>,
156
- options: { wait?: true; timeoutMs?: number }
157
- ): Promise<_ttid>
158
- putData<T extends Record<string, any>>(
159
- collection: string,
160
- data: T,
161
- options: { wait: false; timeoutMs?: number }
162
- ): Promise<_queuedWriteResult>
163
- putData<T extends Record<string, any>>(
164
- collection: string,
165
- data: Record<_ttid, T>,
166
- options: { wait: false; timeoutMs?: number }
167
- ): Promise<_queuedWriteResult>
168
129
 
169
- /**
170
- * Patches a document in a collection.
171
- * @param collection The name of the collection.
172
- * @param newDoc The new document data.
173
- * @param oldDoc The old document data.
174
- * @returns The number of documents patched.
175
- */
176
130
  patchDoc<T extends Record<string, any>>(
177
131
  collection: string,
178
132
  newDoc: Record<_ttid, Partial<T>>,
179
133
  oldDoc?: Record<_ttid, T>
180
134
  ): Promise<_ttid>
181
- patchDoc<T extends Record<string, any>>(
182
- collection: string,
183
- newDoc: Record<_ttid, Partial<T>>,
184
- oldDoc: Record<_ttid, T> | undefined,
185
- options: { wait?: true; timeoutMs?: number }
186
- ): Promise<_ttid>
187
- patchDoc<T extends Record<string, any>>(
188
- collection: string,
189
- newDoc: Record<_ttid, Partial<T>>,
190
- oldDoc: Record<_ttid, T> | undefined,
191
- options: { wait: false; timeoutMs?: number }
192
- ): Promise<_queuedWriteResult>
193
135
 
194
- /**
195
- * Patches documents in a collection.
196
- * @param collection The name of the collection.
197
- * @param updateSchema The update schema.
198
- * @returns The number of documents patched.
199
- */
200
136
  patchDocs<T extends Record<string, any>>(
201
137
  collection: string,
202
138
  updateSchema: _storeUpdate<T>
203
139
  ): Promise<number>
204
140
 
205
- /**
206
- * Deletes a document from a collection.
207
- * @param collection The name of the collection.
208
- * @param _id The ID of the document.
209
- * @returns The number of documents deleted.
210
- */
211
141
  delDoc(collection: string, _id: _ttid): Promise<void>
212
- delDoc(
213
- collection: string,
214
- _id: _ttid,
215
- options: { wait?: true; timeoutMs?: number }
216
- ): Promise<void>
217
- delDoc(
218
- collection: string,
219
- _id: _ttid,
220
- options: { wait: false; timeoutMs?: number }
221
- ): Promise<_queuedWriteResult>
222
142
 
223
- /**
224
- * Deletes documents from a collection.
225
- * @param collection The name of the collection.
226
- * @param deleteSchema The delete schema.
227
- * @returns The number of documents deleted.
228
- */
229
143
  delDocs<T extends Record<string, any>>(
230
144
  collection: string,
231
145
  deleteSchema?: _storeDelete<T>
232
146
  ): Promise<number>
233
147
 
234
- /**
235
- * Joins documents from two collections.
236
- * @param join The join schema.
237
- * @returns The joined documents.
238
- */
239
148
  static joinDocs<T extends Record<string, any>, U extends Record<string, any>>(
240
149
  join: _join<T, U>
241
150
  ): Promise<_joinDocs<T, U>>
242
151
 
243
- /**
244
- * Finds documents in a collection.
245
- * @param collection The name of the collection.
246
- * @param query The query schema.
247
- * @returns The found documents.
248
- */
152
+ joinDocs<T extends Record<string, any>, U extends Record<string, any>>(
153
+ join: _join<T, U>
154
+ ): Promise<_joinDocs<T, U>>
155
+
249
156
  static findDocs<T extends Record<string, any>>(
250
157
  collection: string,
251
158
  query?: _storeQuery<T>
252
159
  ): _findDocs
253
- }
254
160
 
255
- export function migrateLegacyS3ToS3Files(options: {
256
- collections: string[]
257
- s3FilesRoot?: string
258
- recreateCollections?: boolean
259
- verify?: boolean
260
- }): Promise<Record<string, { migrated: number; verified: boolean }>>
161
+ findDocs<T extends Record<string, any>>(
162
+ collection: string,
163
+ query?: _storeQuery<T>
164
+ ): _findDocs
165
+ }
261
166
  }
@@ -1,5 +1,6 @@
1
1
  declare const process: {
2
2
  env: Record<string, string | undefined>
3
+ cwd(): string
3
4
  }
4
5
 
5
6
  declare const Buffer: {
@@ -1,23 +1,24 @@
1
- import { test, expect, describe, afterAll, mock } from 'bun:test'
1
+ import { test, expect, describe, afterAll } from 'bun:test'
2
+ import { rm } from 'node:fs/promises'
2
3
  import Fylo from '../../src'
3
4
  import { postsURL, albumURL } from '../data'
4
- import S3Mock from '../mocks/s3'
5
- import RedisMock from '../mocks/redis'
5
+ import { createTestRoot } from '../helpers/root'
6
6
  const POSTS = `post`
7
7
  const ALBUMS = `album`
8
+ const root = await createTestRoot('fylo-truncate-')
8
9
  afterAll(async () => {
9
- await Promise.all([Fylo.dropCollection(ALBUMS), Fylo.dropCollection(POSTS)])
10
+ const fylo = new Fylo({ root })
11
+ await Promise.all([fylo.dropCollection(ALBUMS), fylo.dropCollection(POSTS)])
12
+ await rm(root, { recursive: true, force: true })
10
13
  })
11
- mock.module('../../src/adapters/s3', () => ({ S3: S3Mock }))
12
- mock.module('../../src/adapters/redis', () => ({ Redis: RedisMock }))
13
14
  describe('NO-SQL', () => {
14
15
  test('TRUNCATE', async () => {
15
- const fylo = new Fylo()
16
- await Fylo.createCollection(POSTS)
16
+ const fylo = new Fylo({ root })
17
+ await fylo.createCollection(POSTS)
17
18
  await fylo.importBulkData(POSTS, new URL(postsURL))
18
19
  await fylo.delDocs(POSTS)
19
20
  const ids = []
20
- for await (const data of Fylo.findDocs(POSTS, { $limit: 1, $onlyIds: true }).collect()) {
21
+ for await (const data of fylo.findDocs(POSTS, { $limit: 1, $onlyIds: true }).collect()) {
21
22
  ids.push(data)
22
23
  }
23
24
  expect(ids.length).toBe(0)
@@ -25,7 +26,7 @@ describe('NO-SQL', () => {
25
26
  })
26
27
  describe('SQL', () => {
27
28
  test('TRUNCATE', async () => {
28
- const fylo = new Fylo()
29
+ const fylo = new Fylo({ root })
29
30
  await fylo.executeSQL(`CREATE TABLE ${ALBUMS}`)
30
31
  await fylo.importBulkData(ALBUMS, new URL(albumURL))
31
32
  await fylo.executeSQL(`DELETE FROM ${ALBUMS}`)
@@ -0,0 +1,7 @@
1
+ import { mkdtemp } from 'node:fs/promises'
2
+ import os from 'node:os'
3
+ import path from 'node:path'
4
+
5
+ export async function createTestRoot(prefix = 'fylo-test-') {
6
+ return await mkdtemp(path.join(os.tmpdir(), prefix))
7
+ }
@@ -1,17 +1,16 @@
1
- import { test, expect, describe, beforeAll, afterAll, mock } from 'bun:test'
1
+ import { test, expect, describe, beforeAll, afterAll } from 'bun:test'
2
+ import { rm } from 'node:fs/promises'
2
3
  import Fylo from '../../src'
3
4
  import { albumURL, postsURL } from '../data'
4
- import S3Mock from '../mocks/s3'
5
- import RedisMock from '../mocks/redis'
5
+ import { createTestRoot } from '../helpers/root'
6
6
  const POSTS = `post`
7
7
  const ALBUMS = `album`
8
8
  let postsCount = 0
9
9
  let albumsCount = 0
10
- const fylo = new Fylo()
11
- mock.module('../../src/adapters/s3', () => ({ S3: S3Mock }))
12
- mock.module('../../src/adapters/redis', () => ({ Redis: RedisMock }))
10
+ const root = await createTestRoot('fylo-create-')
11
+ const fylo = new Fylo({ root })
13
12
  beforeAll(async () => {
14
- await Promise.all([Fylo.createCollection(POSTS), fylo.executeSQL(`CREATE TABLE ${ALBUMS}`)])
13
+ await Promise.all([fylo.createCollection(POSTS), fylo.executeSQL(`CREATE TABLE ${ALBUMS}`)])
15
14
  try {
16
15
  albumsCount = await fylo.importBulkData(ALBUMS, new URL(albumURL), 100)
17
16
  postsCount = await fylo.importBulkData(POSTS, new URL(postsURL), 100)
@@ -20,12 +19,13 @@ beforeAll(async () => {
20
19
  }
21
20
  })
22
21
  afterAll(async () => {
23
- await Promise.all([Fylo.dropCollection(POSTS), fylo.executeSQL(`DROP TABLE ${ALBUMS}`)])
22
+ await Promise.all([fylo.dropCollection(POSTS), fylo.executeSQL(`DROP TABLE ${ALBUMS}`)])
23
+ await rm(root, { recursive: true, force: true })
24
24
  })
25
25
  describe('NO-SQL', async () => {
26
26
  test('PUT', async () => {
27
27
  let results = {}
28
- for await (const data of Fylo.findDocs(POSTS).collect()) {
28
+ for await (const data of fylo.findDocs(POSTS).collect()) {
29
29
  results = { ...results, ...data }
30
30
  }
31
31
  expect(Object.keys(results).length).toEqual(postsCount)
@@ -1,17 +1,16 @@
1
- import { test, expect, describe, beforeAll, afterAll, mock } from 'bun:test'
1
+ import { test, expect, describe, beforeAll, afterAll } from 'bun:test'
2
+ import { rm } from 'node:fs/promises'
2
3
  import Fylo from '../../src'
3
4
  import { commentsURL, usersURL } from '../data'
4
- import S3Mock from '../mocks/s3'
5
- import RedisMock from '../mocks/redis'
5
+ import { createTestRoot } from '../helpers/root'
6
6
  const COMMENTS = `comment`
7
7
  const USERS = `user`
8
8
  let commentsResults = {}
9
9
  let usersResults = {}
10
- const fylo = new Fylo()
11
- mock.module('../../src/adapters/s3', () => ({ S3: S3Mock }))
12
- mock.module('../../src/adapters/redis', () => ({ Redis: RedisMock }))
10
+ const root = await createTestRoot('fylo-delete-')
11
+ const fylo = new Fylo({ root })
13
12
  beforeAll(async () => {
14
- await Promise.all([Fylo.createCollection(COMMENTS), fylo.executeSQL(`CREATE TABLE ${USERS}`)])
13
+ await Promise.all([fylo.createCollection(COMMENTS), fylo.executeSQL(`CREATE TABLE ${USERS}`)])
15
14
  try {
16
15
  await Promise.all([
17
16
  fylo.importBulkData(COMMENTS, new URL(commentsURL), 100),
@@ -20,13 +19,14 @@ beforeAll(async () => {
20
19
  } catch {
21
20
  await fylo.rollback()
22
21
  }
23
- for await (const data of Fylo.findDocs(COMMENTS, { $limit: 1 }).collect()) {
22
+ for await (const data of fylo.findDocs(COMMENTS, { $limit: 1 }).collect()) {
24
23
  commentsResults = { ...commentsResults, ...data }
25
24
  }
26
25
  usersResults = await fylo.executeSQL(`SELECT * FROM ${USERS} LIMIT 1`)
27
26
  })
28
27
  afterAll(async () => {
29
- await Promise.all([Fylo.dropCollection(COMMENTS), fylo.executeSQL(`DROP TABLE ${USERS}`)])
28
+ await Promise.all([fylo.dropCollection(COMMENTS), fylo.executeSQL(`DROP TABLE ${USERS}`)])
29
+ await rm(root, { recursive: true, force: true })
30
30
  })
31
31
  describe('NO-SQL', async () => {
32
32
  test('DELETE ONE', async () => {
@@ -37,7 +37,7 @@ describe('NO-SQL', async () => {
37
37
  await fylo.rollback()
38
38
  }
39
39
  commentsResults = {}
40
- for await (const data of Fylo.findDocs(COMMENTS).collect()) {
40
+ for await (const data of fylo.findDocs(COMMENTS).collect()) {
41
41
  commentsResults = { ...commentsResults, ...data }
42
42
  }
43
43
  const idx = Object.keys(commentsResults).findIndex((_id) => _id === id)
@@ -51,9 +51,11 @@ describe('NO-SQL', async () => {
51
51
  await fylo.rollback()
52
52
  }
53
53
  commentsResults = {}
54
- for await (const data of Fylo.findDocs(COMMENTS, {
55
- $ops: [{ name: { $like: '%et%' } }]
56
- }).collect()) {
54
+ for await (const data of fylo
55
+ .findDocs(COMMENTS, {
56
+ $ops: [{ name: { $like: '%et%' } }]
57
+ })
58
+ .collect()) {
57
59
  commentsResults = { ...commentsResults, ...data }
58
60
  }
59
61
  expect(Object.keys(commentsResults).length).toEqual(0)
@@ -65,7 +67,7 @@ describe('NO-SQL', async () => {
65
67
  await fylo.rollback()
66
68
  }
67
69
  commentsResults = {}
68
- for await (const data of Fylo.findDocs(COMMENTS).collect()) {
70
+ for await (const data of fylo.findDocs(COMMENTS).collect()) {
69
71
  commentsResults = { ...commentsResults, ...data }
70
72
  }
71
73
  expect(Object.keys(commentsResults).length).toEqual(0)