🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@chork/simple-db-repository

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chork/simple-db-repository

Deal with sqlite and postgresql tables using schemas you define in JSON.

0.0.2
latest
npm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Simple DB Repository

Deal with sqlite and postgresql tables using schemas you define in JSON.

Introduction

Here are the features for this node module.

  • Create
  • Read
  • Update
  • Delete
  • Create Tables
  • Drop Tables

Schema

Everything with sqlite repository relies on a schema declaration. Here is the specification.

Simple Schema

const personTable = {
    name: "person",
    version: "1.0.0",
    label: "People",
    description: "A place to store people.",
    columns: [
        {
            type: "INTEGER",
            name: "id",
            label: "Identity"
        },
        {
            type: "TEXT",
            name: "firstName",
            label: "First Name"
        },
        {
            type: "TEXT",
            name: "lastName",
            label: "Last Name"
        }
    ],
    primaryKeys: ["id"]
};

Foreign Keys

const = {
    name: "address",
    label: "Address",
    description: "Address Table",
    version: "1.0.0",
    columns: [
        {
            type: "INTEGER",
            name: "id",
            label:"Identifier"
        },
        {
            type: "TEXT",
            name: "address",
            label: "Address"
        },
        {
            type: "TEXT",
            name: "city",
            label: "City"
        },
        {
            type: "INTEGER",
            name: "state",
            label: "State"
        },
        {
            type: "INTEGER",
            name: "zipCode",
            label: "Zip Code"
        },
        {
            type: "INTEGER",
            name: "personId",
            label: "Person Id",
            isRequired: true
        }
    ],
    primaryKeys:["id"],
    foreignKeys: {
            personId: {
                label: "Person",
                source: {
                    name: "person",
                    version: "1.0.0",
                    label: "Addresses",
                    column: "id"
                }
            }
    }
};

FAQs

Package last updated on 30 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts