Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nestjs mongoose schema nested

// user.schema.ts
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

export type UserDocument = User & Document;

@Schema()
class NestedData {
  @Prop({ type: String })
  foo: string;
  
  @Prop({ type: Number })
  bar: number;
}

@Schema()
export class User {
  @Prop({ type: String, unique: true })
  username: string;
  
  @Prop({ type: String })
  password: string;

  @Prop({ type: NestedData })
  data: NestedData;
}

export const UserSchema = SchemaFactory.createForClass(User);
Comment

nestjs mongoose schema

// user.schema.ts
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

export type UserDocument = User & Document;

@Schema()
export class User {
  @Prop({ type: String, unique: true })
  username: string;
  
  @Prop({ type: String })
  password: string;
}

export const UserSchema = SchemaFactory.createForClass(User);
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to take input from user in javascript console 
Javascript :: 2d arrays js 
Javascript :: js delete url params 
Javascript :: how to use npm package in javascript 
Javascript :: js array map concat 
Javascript :: dart to json 
Javascript :: static in class javascript 
Javascript :: timout 
Javascript :: js array append 
Javascript :: vs code ouput stack 
Javascript :: how to add prefix to a string in javascript 
Javascript :: strip whitespace from shopify liquid output 
Javascript :: javascript DOM SELECT 
Javascript :: useScrollPrecent 
Javascript :: selectize in ajax call 
Javascript :: javascript Rethrow an Exception 
Javascript :: javascript for...of with Sets 
Javascript :: post css nesting nuxt 
Javascript :: !Object.construct polyfill 
Javascript :: Knockout js custom bindings 
Javascript :: fingerprint 
Javascript :: set position phaser 
Javascript :: phaser set x y 
Javascript :: accessing-nested-javascript-objects-and-arrays-by-string-path 
Javascript :: axios imgbb 
Javascript :: Count the number of child records on the each parent object 
Javascript :: documentUrlPatterns 
Javascript :: compare text 
Javascript :: javascript get date value from input 
Javascript :: nodejs extract pdf data 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =