Wednesday, 24 May 2017

Mongoose - Defining a model for a preexisting collection

I have imported some CSV data to my database through mongoimport, which created my collection during the import.

When defining my model in Node, what do I pass for the schema parameter? Viewing my db in compass shows a schema already created based off the imported data.

I'm currently passing an empty schema which seems totally wrong.

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

var Units = new Schema({
});

module.exports = mongoose.model('Units', Units, 'units');



via Phil O'kelly

No comments:

Post a Comment