Code Monkey home page Code Monkey logo

ang-node-nosql's Introduction

This project is a three tier application having presentation, business logic and data layers. We used AngularJS for user interface and Node.js for business logic (accessing data) and multiple NoSQL databases for data storage. Our goal is to have a common user interface and an interoperable middle layer to access various NoSQL databases for performing simple CRUD operation. In the process, we were able to learn multiple NoSQL databases. We believe this work will be useful to others who are in need to explore NoSQL databases in a short period of time and hence we share our work here.

The following NoSQL databases are supported currently.

Local

  • MarkLogic 8
  • Couchbase 4.5
  • Redis 3.2.8
  • MongoDB 3.4.1

Cloud

  • Microsoft Azure DocumentDB
  • Google Cloud Datastore
  • Amazon DynamoDB

Setup

Install/Register a NoSQL Database

DocumentDB
MongoDB - Download
Datastore
DynamoDB

Database Configuration

MarkLogic

Requires configuration if there is a need for custom rest server and custom database.

Couchbase
DocumentDB
Redis

No custom configuration is required

MongoDB

No custom configuration is required

Datastore
  • Create a service account
  • Account Name : sample name
  • Select a Role : Datastore > Datastore Owner
  • Furnish a new private key : Select and keytype: JSON
  • Click on Create button. This will download the .json key file
  • Copy the downloaded json file to the project as /env/datastore.json
DynamoDB
  • Create a AWS account
  • Create access key
    • Select Services -> IAM -> Users -> Add user

      • Enter user name
      • Select Access type for Programmatic access
      • Create user and no need to specify persmissions and skip to complete page
        • Download the .csv file
        • Open the .csv file
        • Copy the access key ID and secret access key to a file and the name the file as /home/user/.aws/credentials (for Mac) or c:\users\user\.aws\credentials as shown below:

          aws_access_key_id = AKIAJJT7TPHFA4ALMAX
          aws_secret_access_key = O2z3Q/cEJSe8cmxf9uFIhK0yPC4McDSjiqgjdXDL
        
        • Select Close
    • Select Services -> IAM -> Users

      • Select the user link that you created and for which downloaded the access key file
      • Select Permissions
        • Select Add inline policy link
          • Select Policy Generator and click Select
            • Select/enter the following values
              • Effect : Allow
              • AWS Service : AWS DynamoDB
              • Actitons : All Actions(*)
              • ARN : *
              • Select Add Statement
              • Select Apply Policy

Application Configuration

MarkLogic

env/marklogic-env.js has the following details. Update if different configuration is required

database: "Documents",
host: "localhost",
port: 8000,
user: "admin",
password: "admin",
authType: "DIGEST"
Couchbase

env/couchbase-env.js has the following details. Change the hostname or bucket name as required

cluster: "couchbase://localhost",
bucket: "default"
DocumentDB

Update env/documentdb-env.js with the details configured on Azure. Details of the URI and Primary key can be found from keys page.

_config.host_ = process.env.HOST || "<URI>";
_config.authKey_ = process.env.AUTH_KEY || "<PRIMARY KEY>";

Alt text

_config.databaseId_ = "documentdb456"; - Any database id can be specified, this will be created from the code
_config.collectionId_ = "tasks"; Any Collection id can be specified, this will created for the above databaseId from the code if it is not created already.

Once the database and collection are created, they can be found here

Alt text

Redis

env/redis-env.js has the following details. Update if different configuration is required

host: "localhost",     
port: 6379
MongoDB

_env/mongodb-env.js has the following details. Update if different configuration is required

host: "mongodb://localhost",     
port: 27017,
database: "myproject"
Datastore

Update env/datastore-env.js with the projectId from Google Cloud Console.

projectId: "sample-id",     
kind : "Tasks"
DynamoDB

Update _env/dynamodb-env.js with the endpoint information if you are using locally installed DynamoDB

Compile/Install

  • Run "npm install" on ang-node-nosql/
  • Run "bower install" on ang-node-nosql/
  • Run "npm install" on ang-node-nosql/client/

If there are changes to client, compile using "npm start" on ang-node-nosql/client/

Run

  • To use MarkLogic as backend NoSQL database use the following command

    node server --env MarkLogic

  • To use Couchbase as backend NoSQL database use the following command

    node server --env Couchbase

  • To use DocumentDB as backend NoSQL database use the following command

    node server --env DocumentDB

  • To use Redis as backend NoSQL database use the following command

    node server --env Redis

  • To use MongoDB as backend NoSQL database use the following command

    node server --env MongoDB

  • To use Google Cloud Datastore as backend NoSQL database use the following command

    node server --env Datastore

  • To use Amazon DynamoDB as backend NoSQL database use the following command

    _node server --env DynamoDB

References

MarkLogic
Couchbase
Microsoft Azure DocumentDB
Redis
MongoDB
Google Cloud Datastore
Amazon DynamoDB

ang-node-nosql's People

Contributors

anandth1974 avatar anodenosql avatar praveen-venkata avatar tvnpraveen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mihaidobri

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.