MongoDB

MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need.

MongoDB
ObjectId

ObjectIds are small, likely unique, fast to generate, and ordered. ObjectId values consist of 12 bytes, where the first four bytes are a timestamp that reflect the ObjectId’s creation. Specifically:

  • 4-byte value representing the seconds since the Unix epoch,
  • 3-byte machine identifier,
  • 2-byte process id, and
  • 3-byte counter, starting with a random value.

In MongoDB, each document stored in a collection requires a unique _id field that acts as a primary key. If an inserted document omits the _id field, the MongoDB driver automatically generates an ObjectId for the _id field.

Other Features

Views : Creating read-only views from existing collections or other views.

Capped Collection : Capped collections are fixed-size collections that support high-throughput operations that insert and retrieve documents based on insertion order. Capped collections work in a way similar to circular buffers: once a collection fills its allocated space, it makes room for new documents by overwriting the oldest documents in the collection.

Data Models & Schema Validation : MongoDB provides the capability to perform schema validation during updates and insertions.

References, Transactions, Indexes, Security, Replication, Sharding.....

Loopback (npm install -g loopback-cli)

The Node.js API Framework
Features

    Set up models and create REST APIs in minutes

  • Easy-to-use CLI wizard
  • Create models based on your schema if you have one
  • Create dynamic models if you don't
  • Built-in API Explorer

    Model relation support

  • Define hasMany, belongsTo, hasAndBelongsToMany relationships
  • Automatically generates corresponding relational REST endpoints

    Easy authentication and authorization setup

  • Built-in role-based access controls
  • oAuth user and registration models baked in
  • Add custom policies using CLI or JSON
  • Browser support (JSONP and CORS)
Datasource

    Connect to backend data stores

  • MySQL, Oracle, MongoDB, Postgres and others
  • Other REST services
  • Discovery APIs for Oracle, MySQL, PostgreSQL and SQL Server

    Run Ad-hoc queries

  • Run dynamic queries on devices, browsers and the server
  • Support for NoSQL-style queries against relational databases
Application Diagram