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 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 And then I tried to execute that code: which works Was not doing I tried again: This time, I got an error, of course - 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 You are trying to run a node script as a mgo shell script . To run this as a regular node script, just use: ideas to see how the data looks, but with clear flexibility, this method is not that information - it's like driving in the dark
script.js file:
var mongoose = is required ('magos'); // ... // Defined Schemas // Try some crazy things // try ... console.log (results);
node script.js
mongo load ('script.js')
required () is not defined by Facepam.
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 ();
node script.js
Comments
Post a Comment