Advanced Node.js Development
上QQ阅读APP看书,第一时间看更新

Running the Todos script

We're going to run the script from the Terminal. I'm going to kick things off by running node. The file we're running is in the server directory, and it's called server.js:

node server/server.js

When we run the file, we get Saved todo, meaning that things went well. We have an object right here with an _id property as expected; the text property, which we specified; and the __v property. The __v property means version, and it comes from Mongoose. We'll talk about it later, but essentially it keeps track of the various model changes over time.

If we open up Robomongo, we're going to see the exact same data. I'm going to right-click the connection and refresh it. Here, we have our TodoApp. Inside of the TodoApp database, we have our todos collection:

Notice that Mongoose automatically lowercased and pluralized Todo. I'm going to view the documents:

We have our one document with the text equal to Cook dinner, exactly what we created over inside of Atom.