<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>MongoDB on David Lang</title>
    <link>https://www.davidlang.tech/tags/mongodb/</link>
    <description>Recent content in MongoDB on David Lang</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Mon, 17 Apr 2023 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.davidlang.tech/tags/mongodb/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Simple Notes app using React, TypeScript, Node.js, GraphQL and MongoDB</title>
      <link>https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/</link>
      <pubDate>Mon, 17 Apr 2023 00:00:00 +0000</pubDate>
      <guid>https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/</guid>
      <description>&lt;p&gt;In the series of the blog post, I am going to walk through step by step process of building a &lt;a href=&#34;https://github.com/rasikjain/SimpleNotes&#34;&gt;Simple Notes&lt;/a&gt; App using &lt;a href=&#34;https://reactjs.org/&#34;&gt;React&lt;/a&gt;, &lt;a href=&#34;https://www.typescriptlang.org/&#34;&gt;TypeScript&lt;/a&gt;, &lt;a href=&#34;https://nodejs.org/en/&#34;&gt;Node.js&lt;/a&gt;, &lt;a href=&#34;https://graphql.org/&#34;&gt;GraphQL &lt;/a&gt;, and &lt;a href=&#34;https://www.mongodb.com/&#34;&gt;MongoDB&lt;/a&gt;. During the process of our development, we are going to use some useful npm packages like &lt;a href=&#34;https://expressjs.com/&#34;&gt;Express&lt;/a&gt;, &lt;a href=&#34;https://www.apollographql.com/docs/apollo-server&#34;&gt;Apollo-Server&lt;/a&gt;, &lt;a href=&#34;https://github.com/typegoose/typegoose&#34;&gt;Typegoose&lt;/a&gt;, &lt;a href=&#34;https://mongoosejs.com/&#34;&gt;Mongoose&lt;/a&gt;, &lt;a href=&#34;https://typegraphql.com/&#34;&gt;TypeGraphQL &lt;/a&gt;, and &lt;a href=&#34;https://getbootstrap.com/&#34;&gt;Bootstrap&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here is the Github &lt;a href=&#34;https://github.com/rasikjain/SimpleNotes&#34;&gt;Source Code&lt;/a&gt; to run the application.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Table of Content&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#dev-environment-setup&#34;&gt;Dev Environment Setup&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#graphql-server-backend&#34;&gt;GraphQL Server Backend&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#folder-structure&#34;&gt;Folder Structure&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#creating-nodejs-project&#34;&gt;Creating Node.js project&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#configuring-typescript&#34;&gt;Configuring TypeScript&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#installing-dependency-packages&#34;&gt;Installing Dependency Packages&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#mongoose-schema-and-graphql-schema&#34;&gt;Mongoose Schema and GraphQL Schema&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#graphql-resolvers&#34;&gt;GraphQL Resolvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#mongo-database-setup&#34;&gt;Mongo Database Setup&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#environment-configuration&#34;&gt;Environment Configuration&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#nodejs-server-setup&#34;&gt;Node.js Server Setup&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#config-files&#34;&gt;Config files&lt;/a&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#packagejson&#34;&gt;package.json&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#nodemonjson-configuration&#34;&gt;nodemon.json configuration&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.davidlang.tech/posts/simple-notes-app-using-react-typescript-nodejs-graphql-mongodb/#running-nodejs--server&#34;&gt;Running node.js / Server&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;dev-environment-setup&#34;&gt;Dev Environment Setup&lt;/h3&gt;&#xA;&lt;p&gt;We are going to set up our initial codebase and folder structure to get started. In this tutorial, I am going to use the Windows environment. The command structure is mostly the same and can be easily replicated to macOS.&lt;/p&gt;</description>
    </item>
    <item>
      <title>MongoDB Best Practices: Schema Design and Indexing</title>
      <link>https://www.davidlang.tech/posts/mongodb-best-practices-schema-design-and-indexing/</link>
      <pubDate>Mon, 25 Oct 2021 00:00:00 +0000</pubDate>
      <guid>https://www.davidlang.tech/posts/mongodb-best-practices-schema-design-and-indexing/</guid>
      <description>&lt;p&gt;MongoDB&amp;rsquo;s flexible documents are powerful-but schema design still matters for performance and maintainability.&lt;/p&gt;&#xA;&lt;h2 id=&#34;embedding-vs-referencing&#34;&gt;Embedding vs Referencing&lt;/h2&gt;&#xA;&lt;p&gt;Embed when data is read together and has a one-to-few relationship (user preferences inside a user doc). Reference when data grows unbounded or is shared (comments on posts).&lt;/p&gt;&#xA;&lt;h2 id=&#34;indexing&#34;&gt;Indexing&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;db.orders.createIndex({ customerId&lt;span style=&#34;color:#719e07&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#2aa198&#34;&gt;1&lt;/span&gt;, createdAt&lt;span style=&#34;color:#719e07&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#719e07&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#2aa198&#34;&gt;1&lt;/span&gt; });&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Compound indexes support queries that filter and sort on the same fields. Use &lt;code&gt;.explain()&lt;/code&gt; to verify index usage.&lt;/p&gt;&#xA;&lt;h2 id=&#34;validation-and-migrations&#34;&gt;Validation and Migrations&lt;/h2&gt;&#xA;&lt;p&gt;Use JSON Schema validation at the collection level. Version documents with a &lt;code&gt;schemaVersion&lt;/code&gt; field for gradual migrations.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
