| 37 | const Tutorial = mongoose.model('Tutorial', mongoSchema); |
| 38 | |
| 39 | async function insertTutorialDocument() { |
| 40 | const tutorial = { |
| 41 | bookSlug: 'builder-book', |
| 42 | tutorials: [ |
| 43 | { |
| 44 | title: 'How to integrate MailChimp in a JavaScript web app', |
| 45 | order: 3, |
| 46 | excerpt: |
| 47 | 'If you are a blogger, publisher, or business owner who does content marketing, having a newsletter is a must. In this tutorial, you will learn how to add Mailchimp integration to a simple JavaScript app...', |
| 48 | domain: 'freecodecamp.com', |
| 49 | link: |
| 50 | 'https://medium.freecodecamp.org/how-to-integrate-mailchimp-in-a-javascript-web-app-2a889fb43f6f', |
| 51 | }, |
| 52 | { |
| 53 | title: 'Add transactional emails to a JavaScript web app (React, Express) with AWS SES', |
| 54 | order: 2, |
| 55 | excerpt: |
| 56 | 'Sending transactional emails is a basic feature of modern web applications. Apps send emails for various reasons. A simple app may send only a welcome email to a newly registered user...', |
| 57 | domain: 'codeburst.io', |
| 58 | link: |
| 59 | 'https://codeburst.io/add-transactional-emails-to-a-javascript-web-app-react-express-9fa1ff2e40e0', |
| 60 | }, |
| 61 | { |
| 62 | title: 'Server-side vs client-side rendering in React apps', |
| 63 | order: 1, |
| 64 | excerpt: |
| 65 | 'In this tutorial, we will take a deeper look at the two types of rendering for web apps: server-side and client-side. I will walk you through basic setup, testing, and comparison of two pages...', |
| 66 | domain: 'hackernoon.com', |
| 67 | link: |
| 68 | 'https://hackernoon.com/server-side-vs-client-side-rendering-in-react-apps-443efd6f2e87', |
| 69 | }, |
| 70 | ], |
| 71 | }; |
| 72 | |
| 73 | const count = await Tutorial.findOne({ bookSlug: 'builder-book' }).countDocuments(); |
| 74 | |
| 75 | if (count === 0) { |
| 76 | Tutorial.create(Object.assign({}, tutorial)); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | insertTutorialDocument(); |
| 81 | |