Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

328
Views
How to create time series collection in mongoDB using Nestjs and mongoose

I am trying to create a time series schema using mongoose in Nestjs. Here's my schema -

import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

export type NewUserModel = NewUser & Document;

@Schema({
  timeseries: {
    timeField: 'timeStamp',
    metaField: 'Name',
    granularity: 'seconds',
  },
})
export class NewUser {
  @Prop({ required: true })
  readonly Name: string;

  @Prop({ required: true })
  readonly Skills: string;

  @Prop({ type: Date })
  readonly timeStamp: Date;
}

export const NewUserSchema = SchemaFactory.createForClass(NewUser);

And here's the json request that I am sending through postman -

{
    "Name": "Nikolia Mangan",
    "Skills": "Management",
    "timeStamp": "2022-06-22T06:22:57.606+00:00"
}

This creates a collection but not a time series collection. I can confirm that by running this command in the shell -

db.runCommand( { listCollections: 1.0 } )

Which in turn returns the output -

"type" : "collection",
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!