Coder Social home page Coder Social logo

indexeddb-cache's People

Contributors

estruyf avatar

Watchers

 avatar  avatar  avatar

Forkers

mhazebroucq

indexeddb-cache's Issues

'CacheService' is not exported by ./node_modules/@valo/cache/dist/index.js

Hi,
I´m Using "@valo/cache": "0.0.1",

I have got this error
'CacheService' is not exported by ./node_modules/@valo/cache/dist/index.js

this is my TS file
import { IMenu } from "./../interfaces/appLists.interfaces";
import { Web } from "@pnp/sp/webs";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";
import { SPFXutils } from "./../services/SPFXutils";
import { CacheService, DateHelper, DateInterval } from '@valo/cache';

export const useMenu = async () => {
(async () => {
await cache.init();
})();

const cache = new CacheService(menuhorizontal);

const getMenu = async (): Promise<IMenu[]> => {
try {
return await cache.get(menuhorizontal);
} catch (error) {
getItensPai().then(async (r) => {
await cache.put(menuhorizontal, r, DateHelper.dateAdd(Date(), DateInterval.minute, 1));
return r;
});
}
};

const getItensPai = async(): Promise<IMenu[]> => {
try {
var menu: IMenu[] = [];
const w = Web(this.siteUrl);
const queryOptions = <QueryOptions><ViewAttributes Scope='RecursiveAll'/></QueryOptions>;
var query = <Query><Where><IsNull><FieldRef Name="pai" /></IsNull></Where><OrderBy><FieldRef Name='SANOrdem1' Ascending='True' /></OrderBy></Query>;
let r = await w.lists.getByTitle(this.listName).renderListDataAsStream({
ViewXml: <view>${query}${queryOptions}</view>,
});
if (r.Row.length > 0) {
for (let i = 0; i < r.Row.length; i++) {
const element = r.Row[i];
//busca filho
var menufilho: IMenu[] = await getItensFilho(element.ID);
var item: IMenu = {
Id: element.ID,
Title: element.Title,
SANLink:
element.SANLinkMult != "" ? element.SANLinkMult : element.SANLink,
SANNewWindown: element.SANNewWindown,
SANOrdem1: element.SANOrdem1,
SANIcon: new SPFXutils().extractIMGUrl(element.SANIcon, "menu"),
Filho: menufilho,
isActive: element.SANLink === window.location.pathname,
openie: element.openIE,
};
menu.push(item);
}
}
return menu;
} catch (error) {
console.error(error);
}
}

const getItensFilho = async(pai: string): Promise<IMenu[]> => {
try {
var menufilho: IMenu[] = [];
const w = Web(this.siteUrl);
const queryOptions = <QueryOptions><ViewAttributes Scope='RecursiveAll'/></QueryOptions>;
var query =
<Query><Where><Eq><FieldRef Name="pai" LookupId='TRUE' /><Value Type="Lookup"> +
pai +
</Value></Eq></Where><OrderBy><FieldRef Name='SANOrdem1' Ascending='True' /></OrderBy></Query>;
let items = await w.lists
.getByTitle(this.listName)
.renderListDataAsStream({
ViewXml: <view>${query}${queryOptions}</view>,
});
if (items.Row.length > 0) {
for (let i = 0; i < items.Row.length; i++) {
const element = items.Row[i];
var menusubfilho: IMenu[] = await getItensFilho(element.ID);
var item: IMenu = {
Id: element.ID,
Title: element.Title,
SANLink:
element.SANLinkMult != "" ? element.SANLinkMult : element.SANLink,
SANNewWindown: element.SANNewWindown,
SANOrdem1: element.SANOrdem1,
SANIcon: new SPFXutils().extractIMGUrl(element.SANIcon, "menu"),
Filho: menusubfilho,
isActive: element.SANLink === window.location.pathname,
openie: element.openIE,
};
menufilho.push(item);
}
}
return menufilho;
} catch (e) {
console.log(e);
}
}

return {
getMenu,
};
};

When calling get() - Database doesn't exist error

Hi Elio,

This is a nice wrapper for IndexedDB and is just what I needed recently. I've been able to Init a database and put a handful of data in it with put(). I can see the data in the browser dev tools and it all looks good. However, when I call get() with my cacheKey it gives me the error "Database doesn't exist.".

My example seems pretty simple. Initializing the service from the constructor like this:

public initCache = async () => {. this.cacheService = new CacheService(cacheDatabaseKey); await this.cacheService.init(); }

Then I try to retrieve it like this:

let cachedData = await this.cacheService.get(myCacheKey);

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.