@cero-base/core 1.16.0 → 1.16.1
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.
- package/package.json +1 -1
- package/src/database/index.js +9 -1
package/package.json
CHANGED
package/src/database/index.js
CHANGED
|
@@ -840,11 +840,19 @@ export class Database extends ReadyResource {
|
|
|
840
840
|
for (const op of ops) this.txQueue.push(op)
|
|
841
841
|
return
|
|
842
842
|
}
|
|
843
|
+
if (!this.bee) throw CeroError.CLOSED('Database')
|
|
843
844
|
if (!this.bee.writable) throw CeroError.NOT_WRITABLE('Database')
|
|
844
845
|
const encoded = ops.map(([op, payload]) =>
|
|
845
846
|
this.spec.dispatch.encode(`@${this.ns}/${op}`, payload)
|
|
846
847
|
)
|
|
847
|
-
|
|
848
|
+
try {
|
|
849
|
+
await this._dryRun(encoded)
|
|
850
|
+
} catch (err) {
|
|
851
|
+
if (!this.bee) throw CeroError.CLOSED('Database')
|
|
852
|
+
throw err
|
|
853
|
+
}
|
|
854
|
+
// the dry-run awaits — the bee can close underneath it
|
|
855
|
+
if (!this.bee) throw CeroError.CLOSED('Database')
|
|
848
856
|
const wrapped = encoded.map((value) => wrap(this.version, value))
|
|
849
857
|
await this.bee.append(wrapped.length === 1 ? wrapped[0] : wrapped)
|
|
850
858
|
}
|