In this days that i have some free time on my “drawing realtime app” project, i have added a managment of the object with the linq.

In c# i use even the linq, but in javascript this is the first time that i use it with success.
Because i have tested https://linqjs.codeplex.com/ some some some times ago but with big object is obviously slow, is even “client side”.

But now with nodejs i can use the linq “server side”, i have seen some library but in my opinion the best is node-linq created by the wearefractal.
Is fast, the docs are good (but they can insert more).

For example i have used it for extract all the action taken in a “drawing room”, for the date i have used timestamp:

var arrRoom = new LINQ(registerRoomAction).Where(function(roomAction) { return (roomAction.room == socket.room && roomAction.date > singleClient.lastupdate && roomAction.date < now); }).OrderBy(function(roomAction) {return roomAction.date;}).Select(function(roomAction) {return roomAction.data;}).ToArray();

 

So if you want to exract only an item you can use Single():

var singleClient = new LINQ(clients).Where(function(client) { return (client.username == username); }).Select(function(client) {return client;}).Single();

 

It is very fast and simple, if you use linq on c#, you are no problem to use it.

For some question you can contact me, i respond to you.

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *