1.0.2 • Published 5 years ago

poom-mongo v1.0.2

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

poom-mongo

A plugin manages mongodb for poom

Install

npm i poom-mongo -S

Examples

Typescript

Config mongo information

import { Mongo } from 'poom-mongo';

Mongo({
    url: 'mongodb://localhost:27017/conn'
});
Mongo({
    key: 'connection1'
    url: 'mongodb://localhost:27017/conn2'
});

Use in service file

import { MONGO, Mongo, Uuid, Collection } from 'poom-mongo';

@Collection('chart')
export class Chart {
    _id?: Uuid;
    name?: string;
    des?: string;
    created_at?: Date;
    updated_at?: Date;
}

export class ChartService {
    @MONGO() 
    static mongo: Mongo;
    
    @MONGO('connection1')
    static mongo1: Mongo;
    
    static async find(fil: any = {}): Promise<Array<Chart>> {
        const rs: Chart[] = await ChartService.mongo.find<Chart>(Chart, fil);
        return rs;
    }
}
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.1

6 years ago