0.1.8 • Published 4 years ago

ts-mongo-codegen v0.1.8

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

TypeScript Mongo Codegen

npm downloads Travis Coverage Status Dev Dependencies Known Vulnerabilities styled with prettier

This project generates types for a seamless integration between GraphQL and MongoDB. Generate All CRUD and Pagination Operations (10 minutes or less)

Usage

yarn add ts-mongo-codegen

./codegen.json

{
  "schema": "http://localhost:8082",
  "generates": {
    "./src/gql/types.ts": {
      "plugins": [
        "typescript",
        "typescript-operations",
        "typescript-resolvers",
        "ts-mongo-codegen",
      ]
    }
  }
}

./gql/books.schema

type Book @collection(name: "books") {
  id: ObjectId
  title: String
  author: String
}

./src/stores/mongo.ts

import { connect } from 'ts-mongo-codegen'
import { mongoFactory } from '../gql/types'

export async function mongoStore(url: string, name: string) {
  const db = (await connect(url)).db(name)
  const datastore = mongoFactory(db)
  // datastore.books is a mongo collection
  return datastore
}

Upcoming Release

  • Augment your schema with CRUD operations for your collections.
  • Generate a changelog to keep a running list of changes to a document
  • Generate subscriptions

Turns This

Example Schema

Into This

Into Tis

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.0.10

4 years ago

0.1.0

4 years ago

0.1.1

4 years ago

0.0.9

4 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago