Closed nurdism closed 6 years ago
Thanks. It seems, that problem is that, npm keeps an own mongoose
version for adapter. Therefore, your Model instance is not inherited from the adapter mongoose version. Currently I don't know why...
A workaround if you uses schema
& modelName
in Service schem instead of model
because in this case you shouldn't require the mongoose
lib.
It works:
module.exports = {
name: "test",
mixins: [DbService],
adapter: new MongooseAdapter("mongodb://localhost/test"),
schema: {
title: { type: String },
content: { type: String },
votes: { type: Number, default: 0}
},
modelName: "test",
afterConnected() {
this.logger.info("Connected successfully...");
return this.adapter.clear().then(() => {
this.logger.info("Seed Posts collection...");
return this.adapter.insertMany([
{ title: "1st post", content: "First post content.", votes: 3 },
{ title: "2nd post", content: "Labore eum veritatis ut.", votes: 8 },
{ title: "3rd post", content: "Rerum deleniti repellendus error ea.", votes: 0 },
{ title: "4th post", content: "Normal post content.", votes: 4 },
{ title: "5th post", content: "Voluptatum praesentium voluptatibus est nesciunt fugiat." }
]);
});
}
}
Yes, I will change it.
I'm running a very simple service, and I just can't get it to work, it just stops after 'Connected successfully...', no errors, it just stops, and I can't for the life of me figure out what is going on. Here's my test repo any help would be much appreciated.