Adding Searching Functionality In Node
In this article we see how we can enable the searching of data from server in our node application.
Setup The Folder
a) Make a new folder using command prompt.Type the following command.
Add New Folder
for more "$regex" usage see this link
Setup The Folder
a) Make a new folder using command prompt.Type the following command.
- mkdir search
- cd search
Setup Node In Folder
For setting up node we type the following command
- npm init -y
it will initialize the node in our project.
And we get a package.json file in our folder.
Which means node is initialized in our folder.
Install Packages
Now we install the packages which will be required for building the application.
- npm install express ejs body-parser mongoose.
- models
- views
- models - this will contain our schema of collections(table).
- views - will contain the ejs pages.
Model
Add new file in folder name it data.js
Views
Add 2 folders
a)pages
b)partial
In partial folder add 2 new files header.ejs and footer.ejs
header.ejs
footer.ejs
In pages add home.ejs file.
home.ejs
Add New File
Add 2 folders
a)pages
b)partial
In partial folder add 2 new files header.ejs and footer.ejs
header.ejs
footer.ejs
In pages add home.ejs file.
home.ejs
Add New File
Add new file name it app.js.
This Will be the entry point of our application
for more "$regex" usage see this link
Comments
Post a Comment