Typegoose not working with @nestjs/mongoose v5.0.0
See original GitHub issueTypegoose stop working after upgrade @nestjs/mongoose from version 4.0.0 to 5.0.0.
I’m submitting a…
[x] Regression
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
When upgrade to version 5.0.0. I cannot make any query to my database.
Expected behavior
Should be working like version 4.0.0
Minimal reproduction of the problem with instructions
Here a simple repository. It is working on version 4.0.0. Then when you upgrade, it’s not working anymore. The working part of typegoose is existingMongoose: mongoose
.
import * as mongoose from 'mongoose';
import { prop, Typegoose } from 'Typegoose';
export class UserSchema extends Typegoose {
@prop({ required: true })
firstName!: string;
@prop({ required: true })
lastName!: string;
@prop({ required: true })
username!: string;
@prop({ required: true })
password!: string;
}
export const User = new UserSchema().setModelForClass(UserSchema, {
schemaOptions: { collection: 'Users', timestamps: true },
existingMongoose: mongoose
});
What is the motivation / use case for changing the behavior?
First when using mongo in nest project, I prefer using Typegoose. It offers a better schema declaration and typings. It is similar to sequelize-typescript when it comes to mongo design. It saving a lot of time to declare interfaces for every mongo schema.
Environment
Nest version: 5.0.1
For Tooling issues:
- Node version: 8.10.0
- Platform: Windows
Others: ...
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
ERESOLVE unable to resolve dependency tree - Stack Overflow
I try to update my Nestjs Backend and have dependency conflicts. Unfortunately I can't figure out what the cause is. I have already...
Read more >nestjs-typegoose - npm
Injects typegoose models for nest components and controllers. Typegoose equivalant for @nestjs/mongoose. Using Typegoose removes the need for ...
Read more >nestjs-typegoose - Bountysource
Hi, I'm testing latest typegoose@beta.11 with mongoose 5.12.9 (tested also with 5.12.10 and 5.12.12 ) but the InjectModel got breaked.
Read more >mongoose | Yarn - Package Manager
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Mongoose supports Node.js and Deno (alpha).
Read more >Nestjs: Property Doesn't Exists In Mongoose Document
My preferred stack is Mongoose, TypeScript, Node.js, React & GraphQL. ... property: string; I have another problem with how to declare sub documents....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Dominic-Preap ok sounds good.
@kamilmysliwiec I’ve answered my own questions. For anyone looking at this in the future, you can get access to the connection by injecting
@Inject('DbConnectionToken') private readonly connection: mongoose.Connection
into the constructor of where you need to use it.@MumblesNZ @kamilmysliwiec I think I’m gonna bypass this issue cause I’ve created the mongoose module using https://docs.nestjs.com/recipes/mongodb and It is working for me.