-
-
Save aheckmann/3965459 to your computer and use it in GitHub Desktop.
Repro for mongoose issue 1127
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vm = require("vm"); | |
var fs = require("fs"); | |
var path = require("path"); | |
var schemaDecl = fs.readFileSync("schema.js", "utf8"); | |
var mongoose = require("mongoose"); | |
mongoose.connect("localhost", "mongoosetest"); | |
var fileName = path.resolve("schema.js"); | |
var script = vm.createScript(schemaDecl, fileName); | |
script.runInNewContext({require: require, __filename: fileName}); | |
var model = mongoose.model("AThing"); | |
model.on("index", function(err) { | |
if (err) console.log(err); | |
mongoose.disconnect(function() { | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require("mongoose"); | |
var Schema = mongoose.Schema; | |
var AThingSchema = new Schema({ | |
name: String, | |
owner: String | |
}, {autoIndex: true}); | |
AThingSchema.index({name: 1, owner: 1}); | |
mongoose.model("AThing", AThingSchema); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment