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.
  • mkdir search
b) change to the new folder
  • 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.

Add New Folder
  • models
  • views
  1. models - this will contain our schema of collections(table).
  2. 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 new file name it app.js.
This Will be the entry point of our application

for more "$regex" usage see this link

Comments

Popular posts from this blog

Upload And Download File In Node

How To Use Sequelize-Cli In Node

Setup Flask Project