Adding keys request
This commit is contained in:
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user