npm

Need private packages and team management tools?Check out npm Orgs. »

@kaviar/nova

1.0.0 • Public • Published

Nova

Build Status TypeScript

Nova is the fetching layer on top of MongoDB Node Driver, which allows SQL-comparable speeds for retrieving relational data. Read the whole history here

GraphQL is treated as a first-class citizen, by offering ability to transform the GraphQL query into a Nova query. You do not have to use GraphQL to use this library

The incredible speed boost is possible thanks to the technology called Hypernova, created by Theodor Diaconu in 2016 for Meteor. Read more about it.

What it solves

  • It makes it bearable to use MongoDB as a relational database
  • Speeds surpassing SQL in various scenarios.
  • Works with GraphQL to avoid over-fetching

Installation

npm i -S @kaviar/nova

Documentation

This provides a learning curve for Nova and it explains all the features.

Sample

import { query, oneToMany } from "@kaviar/nova";
 
async function test() {
  const Post = await db.createCollection("Post");
  const Comments = await db.createCollection("Comments");
 
  oneToMany(Comments, Post, {
    // will automatically read from postId inside Comments
    linkName: "post",
    inversedLinkName: "comments",
  }); // also available manyToMany and manyToOne
 
  query(Post, {
    $: {
      filters: {
        isApproved: true
      }
    }
    title: 1,
    comments: {
      name: 1
    }
  })
}

GraphQL

import { query } from "@kaviar/nova";
 
const Query = {
  // Automatically fetches everything in the minimum amount of queries
  users(_, args, ctx, info) {
    // It passes arguments automatically
    return query.graphql(Posts, info).fetch();
  },
};

Keywords

none

install

npm i @kaviar/nova

Downloadsweekly downloads

4

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability