Add virtual parameters page

This commit is contained in:
Shweelan Samson authored and Zaid Abdulla committed 2018-12-26 00:22:07 -08:00
1 parent 5b84b1daad
commit f9c26dac1a
12 files changed
+453 -20

No files matched your search

+7 -2
View File
@@ -13,9 +13,12 @@ const RESOURCE_DB = {
tasks: "genieacs",
presets: "genieacs",
provisions: "genieacs",
virtualParameters: "genieacs",
files: "genieacs"
};
const RESOURCE_COLLECTION = {};
function getClient() {
if (!_clientPromise)
_clientPromise = new Promise((resolve, reject) => {
@@ -54,7 +57,7 @@ function query(resource, filter, options, callback) {
getClient().then(client => {
const collection = client
.db(RESOURCE_DB[resource])
.collection(resource);
.collection(RESOURCE_COLLECTION[resource] || resource);
let cursor = collection.find(
q,
resource === "Devices"
@@ -130,7 +133,9 @@ function count(resource, filter) {
return new Promise((resolve, reject) => {
getClient().then(client => {
const collection = client.db(RESOURCE_DB[resource]).collection(resource);
const collection = client
.db(RESOURCE_DB[resource])
.collection(RESOURCE_COLLECTION[resource] || resource);
collection.find(q).count((err, c) => {
if (err) reject(err);
else resolve(c);