question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typegoose not working with @nestjs/mongoose v5.0.0

See original GitHub issue

Typegoose 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:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
MumblesNZcommented, Jun 11, 2018

@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.

0reactions
Dominic-Preapcommented, Jun 11, 2018

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found