Since CouchDB doesn't have any collections, I added a custom type
property to my entitys. Now I want to filter all entitys on that property, e.g. get all users by {type:'user'}
. In the couchdb-doc I found a method called 'find()', which is also implemented in the nano typings, but have a lack of documentation in couchdb-nano. According to the definition, I wrote the follwing code:
class UserModel {
type: string = 'User';
name: string = '';
mail: string = '';
}
let db = <nano.DocumentScope<UserModel>>nano("http://localhost:5984/testdb");
let query: nano.MangoQuery = { selector: { type: "User" } };
db.find(query, (cb:nano.Callback<nano.MangoResponse<UserModel>>) => {
// How to get the results here? cb is a callback, but this doesn't make sense
});
It doesn't make sense to me that I get a callback. How can I get the results?
Tried using some kind of callback:
db.find(query, (users: nano.MangoResponse<UserModel>) => {
console.log(users);
});
But users
is undefined, altough the filter { selector: { type: "User" } }
works well in Project Fauxton.