For example I would like to do the following.
Model.find({select: ['id', 'fields.name']}
or something like this?
Model.find({select: ['id', {fields:['name']}]
Is it even possible to do nested selects in waterline?
This question has been answered here
get Selected fields in .populate() waterline-postgresql .populate('fieldName',{select:[]})
select is not supported in .populate(). You can see this github issue. In populate select is not working currently.
This is feature request and it is open issue. hope in next release
waterline team will introduce this feature.
Related
Has anyone found a workaround to allow them to Sort query results using tags in VSO?
The support page clearly states that Excel (as an export should be used).
FYI: https://www.visualstudio.com/en-us/docs/work/track/add-tags-to-work-items
I was hoping someone found a way to sort based on tags where the result is:
- Tag #1
- Feature
- Feature
- Feature
- Tag #2
- Feature
- Feature
- Feature
You can define the query with the clause Tags Contains tagname. If you want to query more than one tag, you can continue add the same clauses with OR operation. Such as query tags t1 and t3 in the query, you can define as:
But the result can’t be ordered by Tags, Which I post an user voice order query result by Tags , you can vote and follow up.
Besides, you can also filter the WIT in Kanban board.
Is there a way to query work items where a user was mentioned? I am able to receive 'hard-coded' results by querying for
"History"-"Contains word"-"\#Username",
but I want a generic version, which works for all users. (Opposed to writing one query for every user)
Use this predicate:
Field: "ID"
Operator: "In"
Value: "#RecentMentions"
This automatically filters for work items, where current user has been mentioned.
I found it in predefined filter "Mentioned" in "Work Items" section. If you click on "Open in Queries" button, you will get a query with above filter. (This section can even remove the need for that query...)
Note: at present time, works only in VSTS.
https://{org}.visualstudio.com/{project}/_workitems/mentioned/
This would achieve the same result.
There is no way to achieve this by work item query directly just as starain mentioned. You can create a custom hub or custom widget by using VSTS Extension to show these information in web portal.
You can’t achieve that through work item query directly, you could build a app to retrieve data through REST API (https://www.visualstudio.com/en-us/docs/integrate/api/wit/wiql), change query text according different conditions (e.g. users)
Your query should be something like this
Select Id,Title From WorkItems Where ID IN (#RecentMentions) order by [System.ChangedDate] desc
here is the reference for rest of the macro's available in ADO rest API.
https://learn.microsoft.com/en-us/azure/devops/boards/queries/query-operators-variables?view=azure-devops
i have such query
Order.find({patient:req.user._id})
.populate({
path:'doctor',
populate:{
path:'specialization',
select:'-_id'
},
})
in this query, if I remove select - everything is working, but when i want select fields which i want (not all ), (select as option working on first level population ) populate no working, can you help me?
This may be occurring because your nested populate is an option for .populate({}) and thus may not have a select option. See the Populating across multiple levels section of this documentation.
You could also try recursively populating. See this answer for more details.
I am trying to execute a DQL (Doctrine) query that retrieve the latest answers of different doctors.
we have table answer, member, Location (doctor table) and many other table connected to the doctor information. However I want to get the latest answer but the condition is one answer for a doctor. I do some search and know something about group by and order by dont work together !
Here is the query in DQL:
$query = Doctrine_Query::create()
->select("a.answer_id as answer_id,m.member_is as member_id,a.member_id")
->from('Answer a')
->leftJoin('a.Member m on m.member_id = a.member_id')
->orderBy('a.date_added DESC')
->groupBy('m.member_id')
->limit(5);
but this query return undesirable results. Can anyone tell me where is the mistake?
Unfortunately you need to perform a subquery for that, which according to this question, DQL does not support. However in that question it's suggested that you send a native query.
i am wondering how can i select specific number of child objects instead of taking them all with include?
lets say i have object 'Group' and i need to select last ten students that joined the group.
When i use '.Include("Students"), EF includes all students. I was trying to use Take(10), but i am pretty new to EF and programming as well, so i couldn't figure it out.
Any suggestions?
UPDATED:
ok, i have Group object already retrieved from db like this:
Group group = db.Groups.FirstOrDefault(x=>x.GroupId == id)
I know that i can add Include("Students") statement, but that would bring ALL students, and their number could be quite big whether i need only freshest 10 students. Can i do something like this: var groupWithStudents = group.Students.OrderByDescending(//...).Take(10);?
The problem with this is that Take<> no longer appears in intellisense. Is this clear enough? Thanks for responses
I believe Take(10) would be correct.
var Students= (from c in Groups
orderby c.DateAdded descending
select c).Take(10);
My experience with Take though is that it generates some awful sql.
EDIT:
see if this blog post helps, it talks of conditional includes.
http://blogs.msdn.com/b/alexj/archive/2009/10/13/tip-37-how-to-do-a-conditional-include.aspx
Couldn't make Gratzy's suggestion with conditional include work... and found the solution here: http://msdn.microsoft.com/en-us/library/bb896249.aspx
Query would look like this:
group.Students.Attach(group.Students
.CreateSourceQuery()
.OrderByDescending(x=>x.JoinDate)
.Take(10));
This is exactly what i was looking for!
Thanks for all responses anyway!