Skip to content

Commit 41546ba

Browse files
committed
comment & cleanup logs
1 parent 6721b92 commit 41546ba

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

packages/db/src/query/compiled-query.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,33 @@ export class CompiledQuery<TResults extends object = Record<string, unknown>> {
7474
}, new Map<unknown, { deletes: number; inserts: number; value: TResults }>())
7575
.forEach((changes, rawKey) => {
7676
const { deletes, inserts, value } = changes
77-
console.log({ deletes, inserts, value, _key: rawKey })
7877
const valueWithKey = { ...value, _key: rawKey }
79-
if (inserts && !deletes) {
80-
console.log(1)
78+
79+
// Simple singular insert.
80+
if (inserts && deletes === 0) {
8181
write({
8282
value: valueWithKey,
8383
type: `insert`,
8484
})
8585
} else if (
86+
// Insert & update(s) (updates are a delete & insert)
8687
inserts > deletes ||
88+
// Just update(s) but the item is already in the collection (so
89+
// was inserted previously).
8790
(inserts === deletes &&
8891
collection.has(valueWithKey._key as string | number))
8992
) {
90-
console.log(2)
9193
write({
9294
value: valueWithKey,
9395
type: `update`,
9496
})
97+
// Only delete is left as an option
9598
} else if (deletes > 0) {
96-
console.log(3)
9799
write({
98100
value: valueWithKey,
99101
type: `delete`,
100102
})
101103
}
102-
console.log(4)
103104
})
104105
commit()
105106
})

packages/db/tests/query/query-collection.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ describe(`Query Collections`, () => {
187187
expect(result.state.get(`4`)).toBeUndefined()
188188
})
189189

190-
it(`should handle deletes`, async () => {
190+
it(`should handle multiple operations corrrectly`, async () => {
191191
const emitter = mitt()
192192

193193
// Create collection with mutation capability

0 commit comments

Comments
 (0)