Saigeie / DCTinder

Tinder but for Discord - find your perfect E dates 😭
Apache License 2.0
1 stars 0 forks source link

TypeScript Mongoose Schema #1

Open vKxni opened 2 years ago

vKxni commented 2 years ago

Hey there, cool project. . Saw your mongoose models, you kinda use the "javascript" style. Tho you could rework it to this: https://typegoose.github.io/typegoose/docs/guides/quick-start-guide/

Example:

class Job {
  @prop()
  public title?: string;

  @prop()
  public position?: string;
}

class Car {
  @prop()
  public model?: string;
}

class User {
  @prop()
  public name?: string;

  @prop({ required: true })
  public age!: number; // This is a single Primitive

  @prop({ type: () => [String] })
  public preferences?: string[]; // This is a Primitive Array

  @prop()
  public mainJob?: Job; // This is a single SubDocument

  @prop({ type: () => Job })
  public jobs?: Job[]; // This is a SubDocument Array

  @prop({ ref: () => Car })
  public mainCar?: Ref<Car>; // This is a single Reference

  @prop({ ref: () => Car })
  public cars?: Ref<Car>[]; // This is a Reference Array
}
Saigeie commented 2 years ago

Ill put it into consideration, ill have to test out this method first on other projects before pushing it to DCTinder, thanks!

vKxni commented 2 years ago

Well you can just write some tests within a test(ing) folder. If you use js it’s fine but with ts I wouldn’t use that