diff --git a/src/database/query.ts b/src/database/query.ts index 09be778..108fadd 100644 --- a/src/database/query.ts +++ b/src/database/query.ts @@ -470,7 +470,7 @@ export class CollectionQuery extends Query { async snapshot(onChange: (change: (DocRes & { type: ChangeTypes })[]) => void) { if (this.subscription) throw new Error("This query is already subscribed!"); - let { collection, document } = await this.resolve(this.path); + let { collection, document } = await this.resolve(this.path, true); let data = await this.get(); @@ -516,6 +516,9 @@ export class CollectionQuery extends Query { public async collections() { + if (!this.session.root) + throw new Error("No Permission!"); + return new Promise((yes, no) => { let keys = []; const stream = this.database.data.createKeyStream({ keyAsBuffer: false }) @@ -526,6 +529,9 @@ export class CollectionQuery extends Query { } public async deleteCollection() { + if (!this.session.root) + throw new Error("No Permission!"); + const { collection, document, collectionKey } = await this.resolve(this.path); if (document) {