I use ionic 4 with pouchdb. I would like to get value from a document.
I wish to get the id_observateur value from a pouchdb document. I tried to use arrows functions but it does not work
let get_observateur = () => {
PouchDB.plugin(PouchDBFind);
PouchDB.plugin(require('pouchdb-adapter-cordova-sqlite'));
this.observateurlocal= new PouchDB('observateurlocal', {adapter:
'cordova-sqlite'});
this.observateurlocal.get('observateurlocal').then((doc) =>{
return doc.id_observateur;
});
};
// Call the function
console.log(get_observateur);
This should work:
let get_observateur = async () => {
PouchDB.plugin(PouchDBFind);
PouchDB.plugin(require('pouchdb-adapter-cordova-sqlite'));
this.observateurlocal = new PouchDB('observateurlocal', {
adapter: 'cordova-sqlite'
});
return await this.observateurlocal.get('observateurlocal');
};
console.log(await get_observateur);
谢谢,Finaly我找到了使用Alldocs和Pouchdb的解决方案
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.