Can I use some scripting to make my mongoose db deployment a little more streamlined?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm a super n00b at setting up servers - just learning back-end stuff right now so I'm having a hard time googling for solutions because my technical language is lacking - I apologize in advance for the n00b question.



I'm following along with a Traversy media video to try and get a little more familiar with setting up a server and using a database to store and retrieve data. The video uses mongoose/mongodb - I've only got a little experience using postgreSQL and I'm not even close to proficient with that so conceptually this is all still pretty unfamiliar.



I'm finding that it's really tedious to open three terminal windows to make my project run properly. I'm using mongoose v5.4.2, express v4.16.4 and (though I doubt it's relevant) I'm using express-handlebars v3.0.0 on the most current version of macOS (10.14.2) (using the native terminal).



In my package.json I have no scripts.



What I'm trying to avoid: having to open a few terminal tabs and run the mongo daemon (cmd: mongod), then running the mongo client in a separate tab (cmd: mongo). I am a noob but this seems like it would be a great place to have some basic scripting to save me from having to do this every time I open the project or make changes to things.



My app.js (which is the entry point to my project) has the following code to import and run mongoose:



const express = require('express')
const exphbs = require('express-handlebars')
const mongoose = require('mongoose')

const app = express()

mongoose.Promise = global.Promise

// Connect to Mongoose
mongoose.connect('mongodb://localhost/vidjot-dev', { useNewUrlParser: true } )
.then(() => console.log('MongoDB Connected'))
.catch(err => console.log(err))


I have verified that my project is running on the specified port (3000 for my project) and I can get my mongoose db running - but only if I run the mongo daemon and then the mongoose client.



Please forgive a lack of specificity/technical correctness in my language - I'm very new to this stuff. I hope that I've provided enough information but edit post to provide anything that anyone else would think is relevant. I used the guided version to post this so I think I hit all the required/expected information.










share|improve this question





























    0















    I'm a super n00b at setting up servers - just learning back-end stuff right now so I'm having a hard time googling for solutions because my technical language is lacking - I apologize in advance for the n00b question.



    I'm following along with a Traversy media video to try and get a little more familiar with setting up a server and using a database to store and retrieve data. The video uses mongoose/mongodb - I've only got a little experience using postgreSQL and I'm not even close to proficient with that so conceptually this is all still pretty unfamiliar.



    I'm finding that it's really tedious to open three terminal windows to make my project run properly. I'm using mongoose v5.4.2, express v4.16.4 and (though I doubt it's relevant) I'm using express-handlebars v3.0.0 on the most current version of macOS (10.14.2) (using the native terminal).



    In my package.json I have no scripts.



    What I'm trying to avoid: having to open a few terminal tabs and run the mongo daemon (cmd: mongod), then running the mongo client in a separate tab (cmd: mongo). I am a noob but this seems like it would be a great place to have some basic scripting to save me from having to do this every time I open the project or make changes to things.



    My app.js (which is the entry point to my project) has the following code to import and run mongoose:



    const express = require('express')
    const exphbs = require('express-handlebars')
    const mongoose = require('mongoose')

    const app = express()

    mongoose.Promise = global.Promise

    // Connect to Mongoose
    mongoose.connect('mongodb://localhost/vidjot-dev', { useNewUrlParser: true } )
    .then(() => console.log('MongoDB Connected'))
    .catch(err => console.log(err))


    I have verified that my project is running on the specified port (3000 for my project) and I can get my mongoose db running - but only if I run the mongo daemon and then the mongoose client.



    Please forgive a lack of specificity/technical correctness in my language - I'm very new to this stuff. I hope that I've provided enough information but edit post to provide anything that anyone else would think is relevant. I used the guided version to post this so I think I hit all the required/expected information.










    share|improve this question

























      0












      0








      0








      I'm a super n00b at setting up servers - just learning back-end stuff right now so I'm having a hard time googling for solutions because my technical language is lacking - I apologize in advance for the n00b question.



      I'm following along with a Traversy media video to try and get a little more familiar with setting up a server and using a database to store and retrieve data. The video uses mongoose/mongodb - I've only got a little experience using postgreSQL and I'm not even close to proficient with that so conceptually this is all still pretty unfamiliar.



      I'm finding that it's really tedious to open three terminal windows to make my project run properly. I'm using mongoose v5.4.2, express v4.16.4 and (though I doubt it's relevant) I'm using express-handlebars v3.0.0 on the most current version of macOS (10.14.2) (using the native terminal).



      In my package.json I have no scripts.



      What I'm trying to avoid: having to open a few terminal tabs and run the mongo daemon (cmd: mongod), then running the mongo client in a separate tab (cmd: mongo). I am a noob but this seems like it would be a great place to have some basic scripting to save me from having to do this every time I open the project or make changes to things.



      My app.js (which is the entry point to my project) has the following code to import and run mongoose:



      const express = require('express')
      const exphbs = require('express-handlebars')
      const mongoose = require('mongoose')

      const app = express()

      mongoose.Promise = global.Promise

      // Connect to Mongoose
      mongoose.connect('mongodb://localhost/vidjot-dev', { useNewUrlParser: true } )
      .then(() => console.log('MongoDB Connected'))
      .catch(err => console.log(err))


      I have verified that my project is running on the specified port (3000 for my project) and I can get my mongoose db running - but only if I run the mongo daemon and then the mongoose client.



      Please forgive a lack of specificity/technical correctness in my language - I'm very new to this stuff. I hope that I've provided enough information but edit post to provide anything that anyone else would think is relevant. I used the guided version to post this so I think I hit all the required/expected information.










      share|improve this question














      I'm a super n00b at setting up servers - just learning back-end stuff right now so I'm having a hard time googling for solutions because my technical language is lacking - I apologize in advance for the n00b question.



      I'm following along with a Traversy media video to try and get a little more familiar with setting up a server and using a database to store and retrieve data. The video uses mongoose/mongodb - I've only got a little experience using postgreSQL and I'm not even close to proficient with that so conceptually this is all still pretty unfamiliar.



      I'm finding that it's really tedious to open three terminal windows to make my project run properly. I'm using mongoose v5.4.2, express v4.16.4 and (though I doubt it's relevant) I'm using express-handlebars v3.0.0 on the most current version of macOS (10.14.2) (using the native terminal).



      In my package.json I have no scripts.



      What I'm trying to avoid: having to open a few terminal tabs and run the mongo daemon (cmd: mongod), then running the mongo client in a separate tab (cmd: mongo). I am a noob but this seems like it would be a great place to have some basic scripting to save me from having to do this every time I open the project or make changes to things.



      My app.js (which is the entry point to my project) has the following code to import and run mongoose:



      const express = require('express')
      const exphbs = require('express-handlebars')
      const mongoose = require('mongoose')

      const app = express()

      mongoose.Promise = global.Promise

      // Connect to Mongoose
      mongoose.connect('mongodb://localhost/vidjot-dev', { useNewUrlParser: true } )
      .then(() => console.log('MongoDB Connected'))
      .catch(err => console.log(err))


      I have verified that my project is running on the specified port (3000 for my project) and I can get my mongoose db running - but only if I run the mongo daemon and then the mongoose client.



      Please forgive a lack of specificity/technical correctness in my language - I'm very new to this stuff. I hope that I've provided enough information but edit post to provide anything that anyone else would think is relevant. I used the guided version to post this so I think I hit all the required/expected information.







      javascript node.js express mongoose






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 at 20:30









      AnthonyAnthony

      326




      326
























          1 Answer
          1






          active

          oldest

          votes


















          1














          I am not completely sure, but it can work to some extent. Add below script in your package.json file.



          "scripts": {
          "prestart": "start mongod --config ./data/mongod.cfg",
          "start": "node ./server/bin/www",
          "poststart": "start mongo admin --eval "db.getSiblingDB('admin').shutdownServer()"",
          },





          share|improve this answer



















          • 1





            Thanks for taking the time to reply. I think I saw a few responses like this so this seems to be the right direction. I'll play around with this for a bit and see where it gets me.

            – Anthony
            Jan 4 at 18:28












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54029368%2fcan-i-use-some-scripting-to-make-my-mongoose-db-deployment-a-little-more-streaml%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I am not completely sure, but it can work to some extent. Add below script in your package.json file.



          "scripts": {
          "prestart": "start mongod --config ./data/mongod.cfg",
          "start": "node ./server/bin/www",
          "poststart": "start mongo admin --eval "db.getSiblingDB('admin').shutdownServer()"",
          },





          share|improve this answer



















          • 1





            Thanks for taking the time to reply. I think I saw a few responses like this so this seems to be the right direction. I'll play around with this for a bit and see where it gets me.

            – Anthony
            Jan 4 at 18:28
















          1














          I am not completely sure, but it can work to some extent. Add below script in your package.json file.



          "scripts": {
          "prestart": "start mongod --config ./data/mongod.cfg",
          "start": "node ./server/bin/www",
          "poststart": "start mongo admin --eval "db.getSiblingDB('admin').shutdownServer()"",
          },





          share|improve this answer



















          • 1





            Thanks for taking the time to reply. I think I saw a few responses like this so this seems to be the right direction. I'll play around with this for a bit and see where it gets me.

            – Anthony
            Jan 4 at 18:28














          1












          1








          1







          I am not completely sure, but it can work to some extent. Add below script in your package.json file.



          "scripts": {
          "prestart": "start mongod --config ./data/mongod.cfg",
          "start": "node ./server/bin/www",
          "poststart": "start mongo admin --eval "db.getSiblingDB('admin').shutdownServer()"",
          },





          share|improve this answer













          I am not completely sure, but it can work to some extent. Add below script in your package.json file.



          "scripts": {
          "prestart": "start mongod --config ./data/mongod.cfg",
          "start": "node ./server/bin/www",
          "poststart": "start mongo admin --eval "db.getSiblingDB('admin').shutdownServer()"",
          },






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 4 at 6:43









          kRiZkRiZ

          326311




          326311








          • 1





            Thanks for taking the time to reply. I think I saw a few responses like this so this seems to be the right direction. I'll play around with this for a bit and see where it gets me.

            – Anthony
            Jan 4 at 18:28














          • 1





            Thanks for taking the time to reply. I think I saw a few responses like this so this seems to be the right direction. I'll play around with this for a bit and see where it gets me.

            – Anthony
            Jan 4 at 18:28








          1




          1





          Thanks for taking the time to reply. I think I saw a few responses like this so this seems to be the right direction. I'll play around with this for a bit and see where it gets me.

          – Anthony
          Jan 4 at 18:28





          Thanks for taking the time to reply. I think I saw a few responses like this so this seems to be the right direction. I'll play around with this for a bit and see where it gets me.

          – Anthony
          Jan 4 at 18:28




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54029368%2fcan-i-use-some-scripting-to-make-my-mongoose-db-deployment-a-little-more-streaml%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Monofisismo

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas