dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

only in findAsync options doesn't seem to do anything #826

Closed markFromMST closed 6 years ago

markFromMST commented 6 years ago

It is possible I misunderstand what only does, but I thought that it was a way of selecting columns to be returned from a search. I could only find examples of its use for the sync form of find, but looking at the source code, I believe this is the way that one would use it:

 dbModels.models.SMS.findAsync(ancestorSearch, {
    limit: 1,
    order: '-minor',
    only: 'minor',
  }).then((results) => {

However, the results returned contain all columns of the table rather than just the 'minor' column. Am I using it incorrectly, or have I found a bug? ORM 4.0.2 on Mac OS with Node 8.9.1

markFromMST commented 6 years ago

I think it returns them all but they are null, so this can probably be closed.

dxg commented 6 years ago

Yeah, it should return data for the single column you requested and other will remain null. If you'd like just an object with columns requested, I recommend using a query builder directly. db.driver.query()