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

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

Description

@treeternity

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});
            
        }
    

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions