import { Injectable } from "@angular/core"; @Injectable({ providedIn: 'root' }) export class JsonStore { /* createCollection(name, data) { var collectionName = name; var addOptions = { // Mark data as dirty (true = yes, false = no), default true. markDirty: true }; var JSONStoreCollections = {}; JSONStoreCollections[collectionName] = {}; JSONStoreCollections[collectionName].searchFields = { UserId: 'integer' }; WL.JSONStore.init(JSONStoreCollections) .then(function () { WL.Logger.debug('Init done'); return WL.JSONStore.get(collectionName).add(data, addOptions); }).fail(function (err) { WL.Logger.error(err); }); } */ getCollection(collectionName) { var allOptions = { // Returns a maximum of 10 documents, default no limit. limit: 10, // Skip 0 documents, default no offset. offset: 0, // Search fields to return, default: ['_id', 'json']. filter: ['UserId', 'json'], // How to sort the returned values, default no sort.}] }; var JSONStoreCollections = {}; JSONStoreCollections[collectionName] = {}; JSONStoreCollections[collectionName].searchFields = { UserId: 'integer' }; /* WL.JSONStore.init(JSONStoreCollections) .then(function () { WL.Logger.debug('Find all colletion data'); }).fail(function (err) { WL.Logger.error(err); }); const data = WL.JSONStore.get(collectionName).findAll(allOptions).then((value) => { return JSON.parse(value); }); return data */ //return notificationData } getColletionById(collectionName, value) { var query = { UserId: value }; var allOptions = { // Returns a maximum of 10 documents, default no limit. limit: 10, // Skip 0 documents, default no offset. offset: 0, // Search fields to return, default: ['_id', 'json']. filter: ['UserId', 'json'], // How to sort the returned values, default no sort.}] }; var JSONStoreCollections = {}; JSONStoreCollections[collectionName] = {}; JSONStoreCollections[collectionName].searchFields = { UserId: 'integer' }; /* WL.JSONStore.init(JSONStoreCollections) .then(function () { WL.Logger.debug('Find colletion data by id'); return WL.JSONStore.get(collectionName).find(query, allOptions).then((value) => { }); }).fail(function (err) { WL.Logger.error(err); }); */ } replaceDocument(collectionName: string, document: any) { /* var document = { Example of how identify the document to replace _id: 1, json: {name: 'chevy', age: 23} }; var options = {}; /* WL.JSONStore.get(collectionName).replace(document, options).then(function (numberOfDocsReplaced) { }).fail(function (error) { }); */ } removeDocument(collectionName: any,query: any,) { /* var query = { _id: 1 }; Exemple of query var options = { exact: true }; /* WL.JSONStore.get(collectionName).remove(query, options).then(function (numberOfDocsRemoved) { }).fail(function (error) { }); */ } }