* feat: zscan

* fix: mongodb tests

* feat: scan, ip search starts with
This commit is contained in:
Barış Soner Uşaklı
2020-07-02 20:11:53 -04:00
committed by GitHub
parent be85123ad5
commit e95cd28f6f
8 changed files with 81 additions and 16 deletions

View File

@@ -42,6 +42,25 @@ module.exports = function (module) {
return res.rows[0].e;
};
module.scan = async function (params) {
let match = params.match;
if (match.startsWith('*')) {
match = '%' + match.substring(1);
}
if (match.endsWith('*')) {
match = match.substring(0, match.length - 1) + '%';
}
const res = await module.pool.query({
text: `
SELECT o."_key"
FROM "legacy_object_live" o
WHERE o."_key" LIKE '${match}'`,
});
return res.rows.map(r => r._key);
};
module.delete = async function (key) {
if (!key) {
return;