<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pro-Tek Blog &#187; Mongodb</title>
	<atom:link href="http://www.pro-tekconsulting.com/blog/category/mongodb/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pro-tekconsulting.com/blog</link>
	<description>For UI developers / UI designers and UI trends</description>
	<lastBuildDate>Thu, 05 Sep 2019 03:59:47 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.34</generator>
	<item>
		<title>CREATING SCHEMAS IN MONGODB USING MONGOOSE</title>
		<link>http://www.pro-tekconsulting.com/blog/creating-schemas-in-mongodb-using-mongoose/</link>
		<comments>http://www.pro-tekconsulting.com/blog/creating-schemas-in-mongodb-using-mongoose/#comments</comments>
		<pubDate>Sat, 01 Dec 2018 04:10:27 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Mongodb]]></category>
		<category><![CDATA[Mongoose]]></category>

		<guid isPermaLink="false">http://www.pro-tekconsulting.com/blog/?p=2749</guid>
		<description><![CDATA[<p>Creating Schemas in MongoDB Using Mongoose MONGOOSE Mongoose is an “elegant MongoDB object modelling for Node.js “. If you have used MongoDB before and tried basic database operations, then you might have noticed that MongoDB is “schema-less”. When you are looking to implement a more structured database and want to leverage the power of MongoDB, [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog/creating-schemas-in-mongodb-using-mongoose/">CREATING SCHEMAS IN MONGODB USING MONGOOSE</a> appeared first on <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog">Pro-Tek Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h4>Creating Schemas in MongoDB Using Mongoose</h4>
<p><strong>MONGOOSE</strong><br />
Mongoose is an “elegant MongoDB object modelling for Node.js “. If you have used MongoDB before and tried basic database operations, then you might have noticed that MongoDB is “schema-less”. When you are looking to implement a more structured database and want to leverage the power of MongoDB, Mongoose is one of the Object Data Mapping (ODM) solutions.</p>
<p>To quickly determine, run an insert command into a collection named users like the following:</p>
<p><img class="aligncenter wp-image-2757" src="http://www.pro-tekconsulting.com/blog/wp-content/uploads/2018/12/Creating-Schemas-in-MongoDB-Using-Mongoose-300x283.jpg" alt="Creating Schemas in MongoDB Using Mongoose" width="300" height="284" /></p>
<p>1db.users.insert({ name : &#8216;Arvind&#8217;, gender : &#8216;male&#8217;});</p>
<p>And right after that, you can run:</p>
<p>1db.users.insert({ name : &#8216;Arvind&#8217;, gender : &#8216;male&#8217;, password : &#8216;!@#$&#8217;});</p>
<p>MongoDB will never complain about the variation in the number of columns (key-value pairs). But when the user wants to keep the data more organized and controlled, the user would need to maintain that in server code, writing validation, making sure nothing unrelated is stored in a collection. This is where Mongoose makes task easy.</p>
<p>Mongoose provides a straight-forward, schema-based solution to modelling the application data and includes built-in typecasting, validation, query building, business logic hooks, and much more, out of the box.</p>
<p>In this article, we are going to show you how to use Mongoose for your MongoDB deployments to create a more straight-forward, schema-based solution to modelling your application data.</p>
<p><strong>START DEVELOPING </strong></p>
<p>After installing Node.js, create a new folder named “myMongooseApp” and open terminal/prompt and run:<br />
1<br />
npm init</p>
<p>This will help the user in setting a new node project. Fill it up as required. Next, install Mongoose as a dependency to the project and run;<br />
npm install mongoose &#8211;save-dev<br />
Then, start the MongoDB service by running:</p>
<p>Mongod</p>
<p>Then, create a new file named index.js at the root and then open it up in favorite editor. Add the below code:</p>
<p>var mongoose = require(&#8216;mongoose&#8217;);<br />
mongoose.connect(&#8216;mongodb://localhost/myTestDB&#8217;);</p>
<p>var db = mongoose.connection;<br />
db.on(&#8216;error&#8217;, function (err) {<br />
console.log(&#8216;connection error&#8217;, err);<br />
});<br />
db.once(&#8216;open&#8217;, function () {<br />
console.log(&#8216;connected.&#8217;);<br />
});<br />
Here, the user requires the Mongoose package to connect to the database and initialize the connection. The name of our database is myTestDB.<br />
Then, run:<br />
node index.js<br />
The user should now see the connected message. The user can also use a node package named nodemon for automatically restarting the node server on changes.</p>
<p><strong>MONGOOSE SCHEMA</strong></p>
<p>Schemas are like skeletons of how the user data collection will look. If the user is dealing with a collection of customers, then the schema would look something like this:</p>
<p>Name &#8211; String<br />
Age &#8211; Number<br />
Gender &#8211; String<br />
Date of Birth &#8211; Date</p>
<p>If the user is dealing with collection of products, then the schema would look like this:</p>
<p>SKU &#8211; String<br />
Name &#8211; String<br />
Price &#8211; Number<br />
InStock &#8211; Boolean<br />
Quantity &#8211; Number</p>
<p>The user can observe the drift. When the data is guarded with a schema, the probability of storing garbage data decreases drastically.</p>
<p>Now that we have got an understanding of schemas, let us try and build a user schema using Mongoose.</p>
<p>var Schema = mongoose.Schema;<br />
var userSchema = new Schema({<br />
name : String,<br />
age : Number,<br />
DOB : Date,<br />
isAlive : Boolean<br />
});</p>
<p>Then, create a model from the schema and add;<br />
var User = mongoose.model(&#8216;User&#8217;, userSchema);<br />
The model is ready and now can use this as base schema to insert users into the database. This way, we know that every document in a user collection will have the fields listed on the schema. Now, let us create a new user instance and save it to DB.<br />
var arvind = new User({<br />
name : &#8216;Arvind&#8217;,<br />
age : 99,<br />
DOB : &#8217;01/01/1915&#8242;,<br />
isAlive : true<br />
});</p>
<p>arvind.save(function (err, data) {<br />
if (err) console.log(err);<br />
else console.log(&#8216;Saved : &#8216;, data );<br />
});<br />
The user should will find something like below:<br />
Saved : { __v: 0,<br />
name: &#8216;Arvind&#8217;,<br />
age: 99,<br />
DOB: Fri Jan 01 1915 00:00:00 GMT+0530 (IST),<br />
isAlive: true,<br />
_id: 536a4866dba434390d728216 }</p>
<p>The post <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog/creating-schemas-in-mongodb-using-mongoose/">CREATING SCHEMAS IN MONGODB USING MONGOOSE</a> appeared first on <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog">Pro-Tek Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pro-tekconsulting.com/blog/creating-schemas-in-mongodb-using-mongoose/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WHAT IS THE DIFFERENCE BETWEEN MONGODB AND MYSQL?</title>
		<link>http://www.pro-tekconsulting.com/blog/what-is-the-difference-between-mongodb-and-mysql/</link>
		<comments>http://www.pro-tekconsulting.com/blog/what-is-the-difference-between-mongodb-and-mysql/#comments</comments>
		<pubDate>Tue, 11 Jul 2017 04:22:10 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Mongodb]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MongoDB and MySQL]]></category>

		<guid isPermaLink="false">http://www.pro-tekconsulting.com/blog/?p=2052</guid>
		<description><![CDATA[<p>What is the difference between MongoDB and MySQL? Although MongoDB and MySQL both are free and open source databases, there is a lot of difference between them in the terms of data representation, relationship, transaction, querying data, schema design and definition, performance speed, normalization and many more. To compare MySQL with MongoDB is like a [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog/what-is-the-difference-between-mongodb-and-mysql/">WHAT IS THE DIFFERENCE BETWEEN MONGODB AND MYSQL?</a> appeared first on <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog">Pro-Tek Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h4>What is the difference between MongoDB and MySQL?</h4>
<p>Although MongoDB and MySQL both are free and open source databases, there is a lot of difference between them in the terms of data representation, relationship, transaction, querying data, schema design and definition, performance speed, normalization and many more. To compare MySQL with MongoDB is like a comparison between Relational and Non-relational databases.<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;</p>
<p>The post <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog/what-is-the-difference-between-mongodb-and-mysql/">WHAT IS THE DIFFERENCE BETWEEN MONGODB AND MYSQL?</a> appeared first on <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog">Pro-Tek Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pro-tekconsulting.com/blog/what-is-the-difference-between-mongodb-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WHAT MAKES MONGODB THE BEST IN INDUSTRY?</title>
		<link>http://www.pro-tekconsulting.com/blog/what-makes-mongodb-the-best-in-industry/</link>
		<comments>http://www.pro-tekconsulting.com/blog/what-makes-mongodb-the-best-in-industry/#comments</comments>
		<pubDate>Tue, 11 Jul 2017 03:57:38 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Mongodb]]></category>
		<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.pro-tekconsulting.com/blog/?p=2049</guid>
		<description><![CDATA[<p>What makes MongoDB the best in Industry? MongoDB is considered to be the best NoSQL database because of the following: Document-oriented (DO) High performance (HP) High availability (HA) Easy scalability Rich query language &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;</p>
<p>The post <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog/what-makes-mongodb-the-best-in-industry/">WHAT MAKES MONGODB THE BEST IN INDUSTRY?</a> appeared first on <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog">Pro-Tek Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h4>What makes MongoDB the best in Industry?</h4>
<p>MongoDB is considered to be the best NoSQL database because of the following:</p>
<ul>
<li>Document-oriented (DO)</li>
<li>High performance (HP)</li>
<li>High availability (HA)</li>
<li>Easy scalability</li>
<li>Rich query language</li>
</ul>
<p>&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;</p>
<p>The post <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog/what-makes-mongodb-the-best-in-industry/">WHAT MAKES MONGODB THE BEST IN INDUSTRY?</a> appeared first on <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog">Pro-Tek Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pro-tekconsulting.com/blog/what-makes-mongodb-the-best-in-industry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MONK VS MONGOOSE FOR MONGODB</title>
		<link>http://www.pro-tekconsulting.com/blog/monk-vs-mongoose-for-mongodb/</link>
		<comments>http://www.pro-tekconsulting.com/blog/monk-vs-mongoose-for-mongodb/#comments</comments>
		<pubDate>Thu, 08 Sep 2016 04:49:38 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Mongodb]]></category>
		<category><![CDATA[Monk vs Mongoose]]></category>

		<guid isPermaLink="false">http://www.pro-tekconsulting.com/blog/?p=1604</guid>
		<description><![CDATA[<p>Monk vs Mongoose for Mongodb Both Monk and Mongoose are distinctive, despite the fact that they are two ways to deal with the same fundamental issue. Mongoose is a very advanced all out ORM. More components, yet more many-sided quality. Monk is smaller in scope and thus easier to understand The better thing is begin [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog/monk-vs-mongoose-for-mongodb/">MONK VS MONGOOSE FOR MONGODB</a> appeared first on <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog">Pro-Tek Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h4>Monk vs Mongoose for Mongodb</h4>
<p>Both Monk and Mongoose are distinctive, despite the fact that they are two ways to deal with the same fundamental issue. Mongoose is a very advanced all out ORM. More components, yet more many-sided quality. Monk is smaller in scope and thus easier to understand</p>
<p>The better thing is begin coding with the essential mongodb driver module straightforwardly. When you see how that functions, and how parts of it are irritating, you will comprehend the advantage of Monk and can give that a shot to check whether you like it. I wouldn&#8217;t prescribe mongoose to a beginner. Mongodb is as of now sufficiently dubious to learn keeping in mind mongoose can be useful, it&#8217;s API is entirely otherworldly and accept you definitely know the precarious parts of mongodb.</p>
<p>The post <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog/monk-vs-mongoose-for-mongodb/">MONK VS MONGOOSE FOR MONGODB</a> appeared first on <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog">Pro-Tek Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pro-tekconsulting.com/blog/monk-vs-mongoose-for-mongodb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
