0.1.6 • Published 7 years ago

inceptum-mongoose v0.1.6

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
7 years ago

Use mongoose in your inceptum project

install

$ yarn add inceptum-mongoose

Add mongoose development configuration

# config/default.yml
# ...
mongoose:
  mongodbUri: mongodb://127.0.0.1:27017/testdb
  connectionOptions:
    autoIndex: false
# ...
also add production environment variables
# config/custom-environment-variables.yml
# ...
mongoose:
  mongodbUri: MONGODB_URI
# ...

Enable the plugin

// src/index.ts
const app = new InceptumApp();

// ...

app.use(
  // ...
  new MongoosePlugin(),
  // ...
);

Make your mongoose models work in typescript

// src/user/user.interface.ts
import { Document } from 'mongoose';

export interface User extends Document {
  email: string,
  password: string,
  // ...
}
// src/user/user.model.ts
import { Document, Schema, Model, model } from 'mongoose';
import { User } from './user.interface';

const userSchema: Schema = new Schema(
  {
    email: String,
    password: String,
    // ...
  },
);

export default model<User>('User', userSchema);
0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago