Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

Attempting to return simple list of documents, small issue #365

Open
treeternity opened this issue Aug 17, 2018 · 0 comments
Open

Attempting to return simple list of documents, small issue #365

treeternity opened this issue Aug 17, 2018 · 0 comments

Comments

@treeternity
Copy link

treeternity commented Aug 17, 2018

Hi there, I am attempting to return a small list of objects (checkins_each), but checkins_each is always returning [] an empty list even though the console.log clearly shows that a bunch of json entries are appended. How do I resolve this?

// return data
    var checkins = nano.use(settings.COUCHDB_PREFIX+'checkins');
    var checkins_each = [];
    checkins.list(function(err, body) {
        if (!err) {
            console.log('hi proximity loop')
            body.rows.forEach(function(doc) {
                console.log(doc.id);
                checkins.get(doc.id, function(err,jsondoc) {
                    console.log(JSON.stringify(jsondoc));
                    if (jsondoc.profile_id != profile_id) {
                        console.log('appending checkin');
                        checkins_each.push(jsondoc);
                    }
                        
                });
            });
            res.send({status: 'proximity', checkins: checkins_each});
        } else {
            console.log("error", err);
            res.send({status: 'fail', error: err});
            
        }
    
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant