Giter Club home page Giter Club logo

Comments (7)

assuncaocharles avatar assuncaocharles commented on June 3, 2024

this.db = new NgxIndexedDB('healthdome', 1);
This line is also in your app component?

from ngx-indexed-db.

elvysferrari avatar elvysferrari commented on June 3, 2024

no, in my contructor of service;
in my app component I inject my service
is the same instance for every app
private _ngxIndexedDbService: NgxIndexedDbService

this._ngxIndexedDbService.getAll("players")

getAll(storeName: string) {
console.log(this.db) //here it brings the instance correctly
this.db.getAll(storeName).then(
obj => {
return obj;
},
error => {
console.log(error);
}
);
}

in console.log(this,db)

db: IDBDatabase
name: "healthdome"
objectStoreNames: DOMStringList
0: "players"
length: 1
dbName: "healthdome"
dbVersion: 1

but getAll not working

from ngx-indexed-db.

elvysferrari avatar elvysferrari commented on June 3, 2024

so is the error

let db = new NgxIndexedDB('healthdome', 1);
db.openDatabase(1);
db.getAll(storeName).then(
obj => {
console.log(obj);
},
error => {
console.log(error);
}
);

You need to use the openDatabase function to create a database before you query it!

from ngx-indexed-db.

assuncaocharles avatar assuncaocharles commented on June 3, 2024

Yes, you are indeed trying to open the database before create it. Just so you can have a better idea, move the creation to inside the constructor of your app.component and you will see it works.

Anyway, can you provide a mini repo with to simulate your problem on stack blitz?

from ngx-indexed-db.

elvysferrari avatar elvysferrari commented on June 3, 2024

You were right, I put it
setTimeout (() => {
       this._ngxIndexedDbService.getAll ("players") / * .then ((ret) => {
         console.log (ret)
       }) * /
       this._ngxIndexedDbService.add ("players", {id: 1, name: "test"})
     }, 5000)

so it's time to create the database, is there any way to check if it's already created?

thank you very much.

from ngx-indexed-db.

assuncaocharles avatar assuncaocharles commented on June 3, 2024

You can have a get function in your service that returns a singleton database and get this database in your app component, and then use it.

from ngx-indexed-db.

elvysferrari avatar elvysferrari commented on June 3, 2024

Good idea, thank you one more time.

from ngx-indexed-db.

Related Issues (20)

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.