npm.io
0.0.14 • Published 8 years ago

mongo-iots-wrapper

Licence
MIT
Version
0.0.14
Deps
5
Size
74 kB
Vulns
1
Weekly
0

Mongo io-ts wrapper

Build Status code style: prettier Known Vulnerabilities

Strongly typed mongod db with runtime validation and typescript intellisense.

Usage

Define your interfaces with io-ts

import * as t from 'io-ts';

const User = t.interface({
    dateCreated: t.number;
    name: t.string;
    email: t.string;
});

Use mongo wrapper to define users collection

const mongoClient = mongoWrapper({
    Collections: {
        users: User
    }
});

Get intellisense

intellisense-preview

Get runtime validation

Invalid value "NotANumber" supplied to : { email: string , dateCreated: number, password: string }/dateCreated: number

Keywords