Savalone47 / mongoose

mongoose CRUD

Home Page:https://mongoosejs.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nodejs Express MongodbMIT license

mongoose CRUD

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const url = 'mongodb://localhost:27017/test';

mongoose.connect(url,{ useNewUrlParser: true}, function () {
	const user1 = new User({firstname: "John", lastname: "Patrick"});
	user1.save(function(err){
		if (err) console.log('Error', err);
		console.log(user1);
	});
});
const userSchema = Schema({
	firstname: String
	, lastname: String
});
const User = mongoose.model('User', userSchema);

RUN

  1. Run mongod and mongo serices (If you get any error like connection faild, just create the folder C:\data\db)
  2. npm run dev: concurrently execute MongoDB, Angular build, TypeScript compiler and Express server.
  3. npm run prod: run the project with a production bundle and AOT compilation

Author

About

mongoose CRUD

https://mongoosejs.com/


Languages

Language:JavaScript 100.0%