Questions tagged [nestjs-mongoose]

46 questions
1
vote
0 answers

NX + Nest Js + Mongoose :- Class.name is not working with nx monorepo style import. but works with absolute path

I am trying to implement an application using nestJs using nx monorepo concept. I ran into one issue which is a bit strange, I can't figure it out how this is happening like this.. I have a organisation schema which is registered in organisation…
Jay
  • 336
  • 1
  • 4
  • 15
1
vote
1 answer

How to add nested array of objects with @Prop decorator from @nestjs/mongoose

When I use a nested array of object in prop decorator: @Schema() export class Child { @Prop() name: string; } @Schema() export class Parent { @Prop({type: [Child], _id: false}) // don't need `_id` for nested objects children:…
1
vote
1 answer

How can I get model reference on the fly nestjs mongoose

So my problem is I have models that is separated by one of our domain's types, and it has a lot of types which each one of em has a dedicated collection. As I know, we can inject the model in the service constructor like this…
fsevenm
  • 791
  • 8
  • 19
1
vote
1 answer

Can't query with condition on relation nestjs/mongoose

I have an Item model, and a Category Model. The item model has a reference (ObjectId) to the Category model. I am writing code to get the items in a specific category. So i get the id of the category as a paremeter(of type string) to the…
evan holt
  • 25
  • 1
  • 4
1
vote
0 answers

Should We use entity without typeorm in nestJS, if we are using mongoose

So, I am not using TypeOrm but mongoose for mongodb. The interfaces I create has no benefits for using Pipes because interface is typescript's behaviour and not Javascript's. I have schema and Document but that too doesn't get into a lot of function…
Abhishek Kumar
  • 820
  • 12
  • 16
1
vote
0 answers

This expression is not constructable. Type 'xxxx' has no construct signatures

I have a mistake that I can't understand what I'm doing wrong. I am following the instructions set out at https://docs.nestjs.com/techniques/mongodb. The difference is that I created interfaces to build different strategies for implementing a…
Aristofanio Garcia
  • 1,103
  • 8
  • 13
0
votes
0 answers

NestJs-Mongoose virtual populate: virtual name throws typeError

mongoose: ^6.6.2 @nestjs/mongoose: ^9.2.0 I've got the following model : export class FormNotificationsLayout { @Prop() public logo?: string; } export class FormNotifications { @Prop() public layout?: FormNotificationsLayout; } @Schema({…
0
votes
1 answer

How to inject dependency in abstract class with NestJs?

Let's say I have an abstract service like bellow abstract class AbstractService { @InjectConnection() connection: Connection } and UserService will extends AbstractService class UserService extends AbstractService { async get () { …
vy.pham
  • 571
  • 6
  • 20
0
votes
0 answers

How to make APP_GUARD run before any Imports module in NestJS

I have a JWT validate middleware like bellow app.module.ts @Module({ imports: [ MongooseModule.forRoot(global.SkeletonConfig.MONGODB_URI), UserModule, ], providers: [ { provide: APP_GUARD, useClass: AuthGuard, }, …
vy.pham
  • 571
  • 6
  • 20
0
votes
1 answer

Nestjs Mongoose issue with query by Date type

I have an issue with Nestjs Mongoose about Date query I used Mongoose for my project. I want to query some documents based on Date field My query looks like: this.model.find(startDate: {$gte: new Date().toUTCString()}) So it will convert to:…
0
votes
2 answers

NestJS: Nest can't resolve dependencies when using mongoose

I have created a new NestJS v9 project, reusing a WORKING module from my previous NestJS v8.2.4 (as part of my research on upgrading to NestJS v9 eventually) but it doesn't compile, claiming it can't find my imported Mongoose model (happens with any…
Sagi Mann
  • 2,967
  • 6
  • 39
  • 72
0
votes
1 answer

Nestjs generate openapi.json output (with mongoose)

I can generate openapi.json from my Nestjs App with no DB connection with the script below. When I'm trying the same with a nest/mongoose dependency I'm can't generate the json file without having a mongoDb connection open first. Does anyone have a…
Nooneelse
  • 127
  • 2
  • 11
0
votes
0 answers

How to perform geospatial queries in mongoose on virtual field?

In my collection records I have documents with such structure: @Schema() export class Record { @Prop() title: string; @Prop() lat: number; @Prop() lon: number; } const RecordSchema =…
lavrent
  • 66
  • 1
  • 5
0
votes
2 answers

How to push subdocument to Mongoose Model with Typescript?

in my NestJS app I have currently an Product schema and a payment method schema as subdocument in the product schema. @Schema() export class Product { @Prop({ required: true }) name: string; @Prop([PaymentDetails]) payments:…
Gerrit
  • 2,515
  • 5
  • 38
  • 63
0
votes
0 answers

NestJS: How to convert Mongoose document to regular class?

I have followed NestJS mongo docs to create a schema (without ID) from a regular class. Since this class has other general uses (unrelated to mongoose), I would like to have regular methods on that class as well: @Schema({ _id: false }) export class…
Sagi Mann
  • 2,967
  • 6
  • 39
  • 72