@mgmguardiana/linqts
v1.0.6
Published
LinqTS is build just like C# Linq and SQL query keywords like "where","not in", "order by asc/desc","orderby/thenby" chain methods and more
Downloads
11
Readme
linqTS
npm install @mgmguardiana/linqts
Import to your typescript file import {Linq} from '@mgmguardiana/linqts/linq';
Initialize instance and use array objects inside the instance using Linq.create export class SampleModel{ constructor(public province:string,public city:string,public barangay:string){} } export class main{ var arrays=[ new SampleModel("Batangas","Calaca","Cawong"), new SampleModel("Cavite","Dasmarinas","San Agustin"), new SampleModel("Batangas","Calaca","Dacanlao"), new SampleModel("Batangas","Balayan","Lanatan"), new SampleModel("Batangas","Balayan","Sampaga") ]; var linq=Linq.create(arrays);//Linq uses generic, it will detect the type that your array use } Sample functions var orderedByProvinceArrays=linq.orderBy(x=>x.province) .toArray(); var orderByThenArrays=linq.orderBy(x=>x.province) .thenBy(x=>x.city) .thenByDescending(x=>x.barangay) .toArray();
var batangasAreas=linq.where(x=>x.province=="Batangas") .toArray(); }