DevTech101

DevTech101

Mongodb

NodeJS and mongoose

npm install mongoose app.js var express = require(‘express’); var os = require(‘os’); // Mongoose import var mongoose = require(‘mongoose’); // Mongoose connection to MongoDB (ted/ted is readonly) mongoose.connect(‘mongodb://127.0.0.1/users’, function (error) { if (error) { console.log(error); } }); // Mongoose Schema definition var Schema = mongoose.Schema; var UserSchema = new Schema({ hostname: String, loadavrg: String, totalmem: …

NodeJS and mongoose Read More »

Using NodeJS With MongoDB

Configuring MongoDB First test and connect to mongo From connect line > use mcfly switched to db mcfly > db.createCollection(‘mathpeeps’) { “ok” : 1 } > db.mathpeeps.insert({Firstname: ‘Eli’, lastname: ‘Kleinman’}) WriteResult({ “nInserted” : 1 }) > db.mathpeeps.insert({Firstname: ‘Moshe’, lastname: ‘Kleinman’}) WriteResult({ “nInserted” : 1 }) > db.mathpeeps.find() { “_id” : ObjectId(“55ce19e7737e49e3a5a7553e”), “Firstname” : “Eli”, “lastname” …

Using NodeJS With MongoDB Read More »