antoniopresto / react-native-local-mongodb

react-native local mongodb storage.
MIT License
303 stars 66 forks source link

Is it possible to wait till document is received ? #56

Closed yspanchal closed 5 years ago

yspanchal commented 5 years ago

Is it possible to wait till document is received in componentdidmount ?

Isfirst = () => { var value = undefined; dB.findOne({'isfirst': true}, function (err, doc){ console.log(doc) value = doc }) return value }

Componentdidmount() { var value = this.Isfirst(); console.log(value); }

antoniopresto commented 5 years ago

I did not understand your question, but you can use db.findAsync, which returns a promise

yspanchal commented 5 years ago

@antoniopresto can please give me an example of dB.findAsync how can I use it ?

Thank you.