Giter Club home page Giter Club logo

s3-db's Introduction

Talaikis Ltd.

AWS S3 JSON Database

This is simple, AWS S3 table-level Node.js JSON database, which we often use in some projects if we want to save on "normal" database deployments.

Preparation

# system preparation:
npm install -g @aws-amplify/cli
amplify configure

# project:
npm i -S @talaikis/s3-db
amplify init
amplify add storage
amplify push

After these operations you will have aws-exports.js configuration file, which you will be able to use for this library init()

Example aws-exports.js

{
    "aws_project_region": "us-east-1",
    "aws_cognito_identity_pool_id": "us-east-1:XXX-XXX-XXX-XXX-XXX",
    "aws_cognito_region": "us-east-1",
    "aws_user_pools_id": "us-east-XXX",
    "aws_user_pools_web_client_id": "XXX",
    "oauth": {},
    "aws_user_files_s3_bucket": "s3-XXX-default",
    "aws_user_files_s3_bucket_region": "us-east-1"
}

Fucntions

All functions need baseDir, where the database is stored. For example: join(__dirname, '.data').

Create item in a table

import { init, create } from '@talaikis/s3-db'
init(awsexports, 'private')
await create(table, itemName, jsonData).catch((e) => ...)

Read item from the table

import { read } from '@talaikis/s3-db'
const jsonData = await read(table, itemName).catch((e) => ...)

Update the item in a table

import { update } from '@talaikis/s3-db'
await update(table, itemName, newJsonData).catch((e) => ...)

Delete item from the table

import { destroy } from '@talaikis/s3-db'
await destroy(table, itemName).catch((e) => ...)

List table items

import { list } from '@talaikis/s3-db'
await list(table).catch((e) => ...)

Delete table (@TODO!)

import { destroyTable } from '@talaikis/s3-db'
await destroyTable(table).catch((e) => ...)

TODO

  • list tables
  • delete table
  • row level ops (?)
  • fix list items mock test

Test

amplify init
amplify add storage
amplify push
amplify mock storage

# other terminal window:
npm run test

Licence

MIT

s3-db's People

Contributors

talaikis avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ejferg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.