|
|
@@ -77,7 +77,29 @@ module.exports = { |
|
|
|
return res; |
|
|
|
}, |
|
|
|
|
|
|
|
getFilterAsync: async function ({ table, noDefault, filter }) { |
|
|
|
getFilterAsync: async function ({ table, noDefault, filter, limit, offset }) { |
|
|
|
let res = r |
|
|
|
.table(table) |
|
|
|
.filter(filter); |
|
|
|
|
|
|
|
if (offset) |
|
|
|
res = res.skip(offset); |
|
|
|
|
|
|
|
if (limit) |
|
|
|
res = res.limit(limit); |
|
|
|
|
|
|
|
await res.run(); |
|
|
|
|
|
|
|
if (res) |
|
|
|
return res; |
|
|
|
|
|
|
|
if (!noDefault) |
|
|
|
return []; |
|
|
|
|
|
|
|
return null; |
|
|
|
}, |
|
|
|
|
|
|
|
getFilterFlat: async function ({ table, noDefault, filter }) { |
|
|
|
const res = await r |
|
|
|
.table(table) |
|
|
|
.filter(filter) |
|
|
@@ -129,6 +151,20 @@ module.exports = { |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
setFlat: async function ({ |
|
|
|
table, |
|
|
|
value, |
|
|
|
conflict = 'update' |
|
|
|
}) { |
|
|
|
try { |
|
|
|
await r.table(table) |
|
|
|
.insert(value, { conflict }) |
|
|
|
.run(); |
|
|
|
} catch (e) { |
|
|
|
this.logError(e, table, JSON.stringify(value)); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
deleteAsync: async function ({ |
|
|
|
key, |
|
|
|
table |
|
|
|