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

@treeternity

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

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