Mark Mark - 6 months ago 46
Node.js Question

lowdb: queries are synchronous or asynchronous?

I'm using


I don't understand this sentence:

the execution of methods is lazy, that is, execution is deferred until .value() is called.

If I have this code:

const post = db.get('posts').find({ id: postId }).value();

may I use
just after that line?


Yes, it looks like it.

The sentence means that adding .get() and .find() methods only refines the eventual query, but by calling .value() the query actually gets executed.

Given the example code, it seems like .value() actually gives you a value, and not a Promise to a value or anything like that.