Procházet zdrojové kódy

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

tags/v0.12.0
Shaun před 1 rokem
rodič
revize
4b05be768a
1 změnil soubory, kde provedl 37 přidání a 1 odebrání
  1. +37
    -1
      src/server/db/ioRethink.js

+ 37
- 1
src/server/db/ioRethink.js Zobrazit soubor

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


Načítá se…
Zrušit
Uložit