0.7.2 • Published 6 years ago

mongoose-model v0.7.2

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

mongoose-model

Build Status NPM version Dependencies status

Installation

Install with npm:

npm install mongoose-model

Usage

import { def, Model, model, prop, Query, ref } from 'mongoose-model';

export interface IContact {
  kind: string;
  value: string;
}

@model
export class User extends Model {
  @prop age: number;
  @prop({
    kind: String,
    value: String,
  })
  contacts: IContact[];
  @prop createdAt: Date;
  @prop email: string;
  @def(false) isActive: boolean;
  @prop name: string;

  get displayName() {
    return `${this.name} <${this.email}>`;
  }

  static findByEmail(email: string): Query<User> {
    return this.findOne({ email });
  }
}

@model
export class Post extends Model {
  @prop body: string;
  @ref  creator: User;
  @prop title: string;

  static findByTitle(title: string): Query<Post> {
    return this.findOne({ title });
  }
}
0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.0

6 years ago

0.5.5

6 years ago

0.5.4

6 years ago

0.5.3

6 years ago

0.5.2

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.9

6 years ago

0.3.8

6 years ago

0.3.7

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.15

7 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

0.0.0

8 years ago