Thursday, 27 April 2017

mongoose ~ simple example ~ does nothing

I'm sorry but ... well

How is that this appears to do nothing? There are not errors, compile or run-time. But the only thing that does happen is the console.log('countryCode');

const mongoose = require('mongoose');
mongoose.set('debug', true);
const countryCodes = require('../schema/countryCodes');
console.log('countryCode');
countryCodes.find({}, function (err, cn) {
    if (err) throw err;
    console.log(cn);
});

-- and the model

var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var countryCodesSchema = new Schema({
    Cn: { type: String, required: true }
    , ProvStName: { type: String, required: true }
);
var mdlCountryCodes = mongoose.model('countryCodes', countryCodesSchema);
module.exports = mdlCountryCodes;

in mongo this returns 400 documents

db.getCollection('countryCodes').find({})



via Steve

No comments:

Post a Comment