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

Where is _id, cmon :( ? #309

Closed
sakenzhuma opened this issue Oct 25, 2021 · 2 comments · Fixed by #311
Closed

Where is _id, cmon :( ? #309

sakenzhuma opened this issue Oct 25, 2021 · 2 comments · Fixed by #311
Labels

Comments

@sakenzhuma
Copy link

sakenzhuma commented Oct 25, 2021

`module.exports = async(app) => {

app.addHook('onRequest', app.auth)

const queries = {
    'locations' : { fields: { _id: 1, name: 1 } },
    'companies': { fields: { _id: 1,  name:1 } },
    'users': { fields: { _id: 1, firstname: 1, lastname: 1 } }
}

app.get('/selection/:node', {} , async(r)=>{
    try {
        const node = xss(r.params.node)
        if(!queries.hasOwnProperty(node)) return app.warning();
        const params = await getParams(r.query)
        const ob = { ...params, ...queries[node] }
        console.log(ob)
        const rows = await cursor.find(app.db[node], ob)
        return app.success(rows)
    }catch(e){
        return onErr(app, e)
    }
})

}`

result:
{ results: [ { name: 'Krakov' }, { name: 'Tashkent' }, { name: 'London' }, { name: 'Aktau' }, { name: 'Turkistan' }, { name: 'Uralsk' }, { name: 'Aqtobe' }, { name: 'Astana' }, { name: 'Boston' }, { name: 'Amsterdam' } ], previous: 'eyIkb2lkIjoiNjE3NWI5MGRiZGY4ODQyZDIxYzFhMmQ1In0', hasPrevious: false, next: 'eyIkb2lkIjoiNjE2YWQ3NmQ4ODFhY2EyNDA1ZDI5ZmI2In0', hasNext: true }

@bradvogel
Copy link
Contributor

Great catch. This regressed with #42.

This line should be moved below line 33.

Want to file a quick PR to fix? :)

leamarty pushed a commit that referenced this issue Nov 18, 2021
When 'paginatedField' is not present, we were not returning
the _id field, even when it was specified to be returned.

resolves #309
mixmax-bot pushed a commit that referenced this issue Nov 18, 2021
### [7.6.1](v7.6.0...v7.6.1) (2021-11-18)

### Bug Fixes

* return _id when paginatedField is not set ([1a056d7](1a056d7)), closes [#309](#309)
@mixmax-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 7.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants