I want to create a function for dynamic find document in Meteor.js.
For instance I have Students
Collection and I want to find students by name, gender, phone...
. if name is provide I want to find name like
the name that is provided, if gender
is provide I want to find gender which is equal to gender that is provided, if phone
is provide I want to find phone like the phone that is provided, and if name
or gender
or phone
is not provided, I want to find the all the name and all gender and all phone.
In SQL Server I will create the stored Procedure like this:
Create PROCEDURE [dbo].[pG_Student]
@pName nvarchar(250)=null,
@pGender nvarchar(50)=null,
@pPhone nvarchar(100)=null
AS
BEGIN
SELECT * FROM [dbo].[StudentView]
WHERE (LOWER(Name) like '%'+LOWER(@pName)+'%' or @pName is null)
and (Gender=@pGender or @pGender is null)
and (LOWER([Phone]) like '%'+LOWER(@pPhone)+'%' or @pPhone is null)
END
With this Stored Procedure I can call with C#.
How about with Meteor.js?