node.js - How can I interact with MongoDB via Mongoose without Express? -


I want an environment where I work with CRUED, ​​it can get a solid understanding. To this point, I am using ideas to see how the data looks, but with clear flexibility, this method is not that information - it's like driving in the dark

Now I want to be able to work with the data in MongoDB through the functionality offered by MongoDB so that I can see that when I do this or sub-document, population, initially , M This code was in the script.js file:

  var mongoose = is required ('magos'); // ... // Defined Schemas // Try some crazy things // try ... console.log (results);   

And then I tried to execute that code:

node script.js

which works Was not doing I tried again:

  mongo load ('script.js')   

This time, I got an error, of course - required () is not defined by Facepam.

Hope you find out what I am trying to do. I have tried other methods since then which did not seem to work.

Please advise.

UPDATE

And here is my script.js file:

  var hero = Required ('./ hero-model'); // It defines Hero-Model.JS file schema // and exports its functionality. I have successfully used this model via CRUD data // Express. You can ignore the above code, where I said ('mongos') because I was just // Simple to run this script, // the command ends silently due to Var getHeroes = function () {Hero.find (function (err, heroes) {if (err) {console.log (err);} console.log (heroes);}); }; GetHeroes ();    

You are trying to run a node script as a mgo shell script . To run this as a regular node script, just use:

  node script.js    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -