Comments (7)
this.db = new NgxIndexedDB('healthdome', 1);
This line is also in your app component?
from ngx-indexed-db.
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.
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.
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.
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.
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.
Good idea, thank you one more time.
from ngx-indexed-db.
Related Issues (20)
- updateByKey give an error. HOT 2
- Version is incrementing for dynamically added store and keeps on incrementing with every page refresh HOT 2
- console log when using update
- Angular 14 HOT 3
- Readme for cursor api is not valid HOT 1
- Test HOT 1
- ngx-indexed-db version 11.0.2, cannot make it work with Angular 11 HOT 2
- Support cursor direction
- Check current version HOT 3
- is it possible to handle errors when adding record with existing key?
- Add testing module to handle mocking the indexedDb and easily fetching the info for assertions in unit tests HOT 1
- Unable to delete database because it's blocked HOT 14
- Get all object store names
- Support for "out-of-line" keys? HOT 6
- como faço criar o Index , nas tabelas ? HOT 1
- Link in Description opening a Download
- What is the current Version? HOT 1
- Property 'continue' does not exist on type 'IDBDatabase'.
- Version 17 imports seem broken HOT 5
- Support for Angular 17 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-indexed-db.