Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

co-monk yield call not working on function generator inside a class #8

Open
wmehanna opened this issue Jan 9, 2016 · 0 comments
Open

Comments

@wmehanna
Copy link

wmehanna commented Jan 9, 2016

I'm getting undefined ouput when calling for the returned value comming from the yield call.
It worked with co library.

here's my code :

"use strict";

 var monk = require("monk");
 var wrap = require("co-monk");
 var db = monk("localhost/test");
 var users = wrap(db.get("users"));

 class User {

    constructor(user) {
        if (typeof user == "object") {

            var findUser = this.findOne(user.id);
            findUser.next();
            findUser.next();

            if(findUser != null){
                this._user = user;
            }

        }
        else {
            console.error("user parameter is not an oject");
            return false;
        }
    }

    *findOne(id) {

        var userData = yield users.findOne({_id: id});

        console.log(userData); // Getting undefined

        this._user = userData;

    };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant