mongo-portable

Portable Pure JS MongoDB - Based on Monglodb (https://github.com/euforic/monglodb.git) by Christian Sullivan (http://RogueSynaptics.com)

Usage no npm install needed!

<script type="module">
  import mongoPortable from 'https://cdn.skypack.dev/mongo-portable';
</script>

README

MongoPortable

Solution for a MongoDB-like portable database.

Package Version NodeJS Version

Travis Build Appveyor Build Codeship Build

Test Coverage Downloads Documentation Status

MongoPortable is a module that handles collections and documents in memory, and allow the use of stores for persistence.

This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to eduardo.astolfi91.com.

Installation

npm install mongo-portable
yarn add mongo-portable

Usage

// Declaring the module dependency
import { MongoPortable } from "mongo-portable";

// Instantiates a new ddbb object by passing a ddbb name
let db = new MongoPortable("DB_NAME");

// Creates a new collection named "users" 
//      (if it's already created, it will just return it instead)
db.collection("users").then(collection => {
    // Inserts a new document into the collection
    collection.insert({ name: "John", lastName: "Abruzzi" }).then(document => {
        console.log(document);  // -> { name: "John", lastName: "Abruzzi" }
        
        // Performs a query against this collection, fetching all the results
        users.find({ name: "John" }).then(documents => {
            console.log(documents);  // -> [ { name: "John", lastName: "Abruzzi" } ]
        });
    });
});

Modules

The main modules available are MongoPortable and Collection (and Cursor when using the "doNotFetch" option).

MongoPortable

Handles the database, collections and connections.

Read the full API documentation here

Collection

Handles the list of documents by using cursors.

Read the full API documentation here

Cursor

Fetchs and access the documents to return them to the client.

Read the full API documentation here


Stores

File System Store

It is located in a separated module, so install it by:

npm install file-system-store
yarn add file-system-store

And then use it in your application by adding it in your MongoPortable instance:

import { FileSystemStore } from "file-system-store";

db.addStore(new FileSystemStore(/* options */));

or as a middleware:

import { FileSystemStore } from "file-system-store";

db.use("store", new FileSystemStore(/* options */));

View the package here and read the full API documentation here


Contributing

Feel free to contribute with your own ideas / fixes!

There is a [to-do list](#TO-DO List) with the features I'd like to add in the feature, and a serie of milestones with the roadmap I have in mind. Take a look at them if you want to :)

Every contribution should be addressed with a well-formed pull request -> Contributing


License

MIT