file-system-store

File System Store for MongoPortable, a portable MongoDB module (https://github.com/eastolfi/MongoPortable)

Usage no npm install needed!

<script type="module">
  import fileSystemStore from 'https://cdn.skypack.dev/file-system-store';
</script>

README

FileSystemStore

File System Store for persistence with MongoPortable, a portable MongoDB-like module.

Package Version NodeJS Version

Linux Build Windows Build Test Coverage Downloads Documentation Status

Persists the collection and documents received by the MongoPortable module.

Installation

npm install --save file-system-store

NOTE: This module complements MongoPortable, a MongoDB-like portable database. If you don't have it installed, please read the documentation.

Usage

// Declaring the modules dependencies
var MongoPortable = require("mongo-portable"),
    FileSystemStore = require("file-system-store");

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

// Tells MongoPortable to use this store to persist the data
db.addStore(new FileSystemStore({
    // The path where the database will be stored
    ddbb_path: "MY_PHISICAL_DDBB_PATH",
    // Whether the persistance will be asynchronous or not
    sync: true
}));

// Creates a new collection named "users" 
//      (if it's already created, it will just return it instead)
var users = db.collection("users");

// Inserts a new document into the collection
var document = users.insert({ name: "John", lastName: "Abruzzi" });
console.log(document);  // -> { name: "John", lastName: "Abruzzi" }

// Creates a cursor with the query information, ready to be fetched
var cursor = users.find({ name: "John" });

// Iterates over the cursor, obtaining each document that matchs the query
cursor.forEach(function(doc) {
    console.log(doc);  // -> { name: "John", lastName: "Abruzzi" }
});

Currently, we are supporting simple CRUD operations.

TO-DO List

Collection Operations

  • Create
  • Drop

Documents Operations

  • Creating
    • .insert()
    • .save()
  • Reading
    • .find()
    • .findOne()
  • Updating
    • .update()
  • Deleting
    • .remove()

Indexes Operations

  • createIndex
  • ensureIndex
  • dropIndex
  • reIndex

Backups Operations

  • backup
  • backups
  • removeDackup
  • restore

License

MIT