Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm new to javascript and i just wanted to know if there is a LinQ equivalent in vue. My goal is to do something like this :
this.selection = this.clientsComplete.Where(
c => c.id == eventArgs.sender.id);
On a collection made like this :
clientsComplete: [
id: 1,
title: "Client1",
description: "Unknown",
sites: [
{ id: 1, title: "Site1-1", description: "Unknown" },
{ id: 2, title: "Site1-2", description: "Unknown" }
id: 2,
title: "Client2",
description: "Inconnue",
sites: [
{ id: 1, title: "Site2-1", description: "Unknown" },
Is this event possible in vue? I can't find anything in the documentation about selection in Lists.
If there is no LinQ equivalent, do I have to do a foreach to find my object ?
How about using plain javascript? There are powerful array functions that can get you there.
For example:
this.clientsComplete.filter(c => c.id == eventArgs.sender.id)
is very similar to what LINQ Where does.
More info here.
Edit: this uses ES6 arrow functions but it can also be written without it.
–
https://www.npmjs.com/package/manipula is javascript LINQ equivalent. Example:
this.selection = Manipula.from(this.clientsComplete)
.where(c=> c.id == eventArgs.sender.id)
.toArray();
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.