These are chat archives for Automattic/mongoose

10th
Nov 2017
Arun Gadag
@arun-awnics
Nov 10 2017 04:48 UTC
@tehstormcrow Logger is a library
You need to import it before using it
const log4js = require('log4js');
log4js.configure('configuration');
var logger = log4js.getLogger();
Then start using logger in your app
piyush
@piyushimraw
Nov 10 2017 09:22 UTC

var express = require ("express");
var app = express();
var bodyParser = require("body-parser");
var mongoose = require ("mongoose");

mongoose.connect("mongodb://localhost:27017/lets_camp", { useMongoClient: true });
app.use(bodyParser.urlencoded({extended: true}));
app.set("view engine", "ejs");

/var campgrounds = [
{name: "Okhala", image: "https://farm8.staticflickr.com/7252/7626464792_3e68c2a6a5.jpg"},
{name: "River's Dawn", image: "https://farm4.staticflickr.com/3872/14435096036_39db8f04bc.jpg"},
{name: "Bird's Paradise", image: "https://farm3.staticflickr.com/2924/14465824873_026aa469d7.jpg"},
{name: "Adventure Rocks", image: "https://farm3.staticflickr.com/2353/2069978635_2eb8b33cd4.jpg"},
]
/

// SCHEMA setup
var campgroundSchema = new mongoose.Schema({
name : String,
image : String

});

var Campground = mongoose.model("Campground", campgroundSchema);

Campground.create = (
{
name : "piratespie",
image : "https://farm8.staticflickr.com/7252/7626464792_3e68c2a6a5.jpg"

}, function(err, campround){
if(err){
console.log(err);
}else {
console.log("Newly created campgrounds");
console.log(campground);
}
});

no output on the consol.log
var express     = require ("express");
var app         = express();
var bodyParser  = require("body-parser");
var mongoose     = require ("mongoose");

mongoose.connect("mongodb://localhost:27017/lets_camp", { useMongoClient: true });
app.use(bodyParser.urlencoded({extended: true}));
app.set("view engine", "ejs");




/*var campgrounds = [
        {name: "Okhala", image: "https://farm8.staticflickr.com/7252/7626464792_3e68c2a6a5.jpg"},
        {name: "River's Dawn", image: "https://farm4.staticflickr.com/3872/14435096036_39db8f04bc.jpg"},
        {name: "Bird's Paradise", image: "https://farm3.staticflickr.com/2924/14465824873_026aa469d7.jpg"},
        {name: "Adventure Rocks", image: "https://farm3.staticflickr.com/2353/2069978635_2eb8b33cd4.jpg"}, 
    ]*/

// SCHEMA setup
var campgroundSchema = new mongoose.Schema({
    name : String,
    image : String

});

var Campground = mongoose.model("Campground", campgroundSchema);

Campground.create  = (
{
    name : "piratespie",
    image : "https://farm8.staticflickr.com/7252/7626464792_3e68c2a6a5.jpg"

}, function(err, campround){
    if(err){
        console.log(err);
    }else {
        console.log("Newly created campgrounds");
        console.log(campground);
    }
});
no output on console