Adding keys request

This commit is contained in:
Fabian Stamm
2019-10-11 21:13:21 +02:00
parent 6036556a37
commit 15df0351a4
2 changed files with 20 additions and 1 deletions

View File

@ -74,6 +74,19 @@ export default class Query {
});
}
async keys() {
const lock = await this.database.locks.lock(this.path);
try {
let obj = await this.getField(this.path);
if (!obj)
return [];
let fields = await this.getFields(this.path);
return fields.map(field => field.split("/").filter(e => e !== "")).filter(path => path.length === this.path.length + 1).map(path => path.pop());
} finally {
lock()
}
}
async get() {
const lock = await this.database.locks.lock(this.path);
try {
@ -243,6 +256,7 @@ export default class Query {
if (type === ChangeTypes.PUSH) {
send({
id: change.path[change.path.length - 1],
path: change.path,
data: await new Query(this.database, change.path).get()
})
} else {