Browse Source

feat #1945: Added limit and offset to getFilterAsync and implemented setFlat

tags/v0.12.0
Shaun 1 year ago
parent
commit
4b05be768a
1 changed files with 37 additions and 1 deletions
  1. +37
    -1
      src/server/db/ioRethink.js

+ 37
- 1
src/server/db/ioRethink.js View File

@@ -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


Loading…
Cancel
Save