@resistdesign/cjs

0.0.3 • Public • Published

Collection JS

A JavaScript Database Collection Manager with Context Driven Typing and Relationship Mapping.

Installation

Run npm i -S @resistdesign/cjs

Usage

import Collection from '@resistdesign/cjs';

async function createTodo() {
  const todoContext = {
    title: String,
    description: String,
    createdOn: Date
  };
  // Cyclical, nested items.
  todoContext.childTodos = [todoContext];
  const todos = await Collection.getCollectionStructure({
    name: 'Todos',
    db: 'mongodb://localhost:27017/example-db',
    context: todoContext,
    deleteNested: {
      childTodos: true
    }
  });
  const createdOn = new Date();

  return await todos.create([
    {
      title: 'Wash Clothes',
      description: `Get them very clean, you're going to need to look your best! :)`,
      createdOn
    },
    {
      title: 'Jump Rope',
      description: 'Time to stay in shape!',
      createdOn,
      childTodos: [
        {
          title: 'Learn Tricks',
          description: `You'd look silly just hopping up and down like that without a little pizzazz.`,
          createdOn
        }
      ]
    }
  ]);
}

createTodo();

API

View the API documentation here.

License

MIT

Package Sidebar

Install

npm i @resistdesign/cjs

Weekly Downloads

1

Version

0.0.3

License

MIT

Last publish

Collaborators

  • resistdesign