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

156
Views
initialize mongoose collection with default documents

is there a way to initialize the mongoose collection with default documents I did take a look at mongoose docs i didn't find a hook to help me achieve what I want

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

export type NetworkDocument = Network & mongoose.Document;
@Schema({
  versionKey: false,
  timestamps: { createdAt: 'created-at', updatedAt: 'updated-at' },
})
export class Network {
  @Prop({ unique: true })
  'network-id': number;

  @Prop({ required: true })
  'labels': string[];


}
export const NetworkSchema = SchemaFactory.createForClass(Network);

NetworkSchema.pre('save', () => {
  console.log('network model saved');
});

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!