dderevjanik / mongo-iots-wrapper

Strongly typed Mongo DB with runtime validation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Strongly typed Mongo DB with runtime validation


Languages

Language:TypeScript 100.0%