Mongoose learning comprehension (recommended) and mongoose learning Comprehension
1. Create schemas
How to Create schemas:
var userSchema = new mongoose.Schema({ name: String, email: String, createdOn: Date });
Schemas has the following data
MongoDB's basic use of MongoDB features:
Storing data using Bson
Supports relatively rich query operations (relative to other NoSQL databases)
Support Index
Replica set (supports multiple instances/multiple servers running the
Mongoose simple table connection query and Mongoose simple
The original article is taken from my front-end blog. You are welcome to visit
Http://www.hacke2.cn
As I mentioned in this article, it is based on Node. js + jade + Mongoose mimic gokk. TV,
Data model and Base operation templateIn order to make the engineering structure clear, the establishment of data Model (SCHEMA) and the base operation template of adding and deleting and modifying are named as collection in database design
The restfull routes are as follows:Router.get ('/:id ', controller.show);The Mongoes code is as follows:function (req, res) { function ( err, notice){if(err) { Res.json ({no: 0,msg: ' Get failed: ' +err} '; } Else { var result =
The original article is taken from my front-end blog. You are welcome to visit
Http://www.hacke2.cn
As I mentioned in this article, it is based on node. JS + Jade + mongoose mimic gokk. TV, at that time, the development was stopped because I deeply
A burst of Byron teacher spoke about MongoDB's crud operations, including:How to create a new database (use dbname), delete a database (use dbname →db.dropdatabase ()), add data (db. CollectionName. Insert ({}) to view the data in the table (db.
There is no join in mongoose but sometimes we still want to refer to other collection document,population.Population is the process of automatically replacing the document specified in document with another collection. We can migrate document,
Mongoose is an node.js mongodb object Model tool for convenient operation in the environment.
Therefore, to use mongoose , you must install the node.js environment and the mongodb database. Mongoose makes MongoDB operations easier and easier.
Using mongoose allows us to better use the MongoDB database without having to write tedious business logic.
Installation
NPM Install Mongoose
Initialize the use ofbefore using mongoose, you need to install node and MongoDB, which do
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.