RajiDurai / customer-management-backend

To display a customer list based on filters set to customer's firstName, lastName and companyName
0 stars 0 forks source link

Connect to the database replacing mock data #3

Open RajiDurai opened 3 months ago

RajiDurai commented 3 months ago

install mongo db

RajiDurai commented 3 months ago

The above install doesn't work. So choosing homebrew was successful Source : link

To start mongo service, use brew services start mongodb/brew/mongodb-community To access mongo shell, use mongosh. (Note. command 'mongo' doesn't work after version 6)

RajiDurai commented 3 months ago

run db.getMongo() method to return the connection string in your local

Mongo-db video tutorial : https://www.youtube.com/watch?v=B86Gw3kiA0M&list=PLFub7_BptrW8chs-qC-BsPIHH7Xe3_5Ib&index=4

RajiDurai commented 3 months ago

install dependencies for mongo in node - npm i mongoose

RajiDurai commented 2 months ago

The below model is successfully set up const customerSchema = new mongoose.Schema({ firstName: {type: String, required: true}, lastName: {type: String, required: true}, companyName: {type: [String], required: true}, }, {collection : 'Customer'});

with below connect params

const conParams = { useNewUrlParser: true , dbName : 'customerSchema'};// added here dbName after 5 hrs scratching my head mongoose.connect(process.env.DB, conParams);

RajiDurai commented 2 months ago

Done