🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

mongo-local-db

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongo-local-db

mongo api interface to localStorage and plain js objects

1.1.3
latest
Source
npm
Version published
Maintainers
1
Created
Source

Mongo-Local-DB

A JavaScript implementation of the mongo query api for plain objects and HTML5 localStorage.

There are two main use cases that Mongo-Local-DB targets:

  • providing a mongo interface to localStorage in HTML5 web browsers
  • for use as an in memory mongo database that can be used in the browser or nodejs

Build Status Coverage Status

In Node.js

Installation

npm install mongo-local-db

Usage

var mongo = require('mongo-local-db');
var db = new mongo.DB()
db.createCollection("sample")
db.sample.insert({ age: 4,	legs: 0	});
db.sample.insert([{ age: 4,	legs: 5	},{ age: 54, legs: 2	}]);
db.sample.insertMany([{ age: 54, legs: 12 },{ age: 16					 }]);
db.sample.insertOne({ name: "steve"		 });
var cur = db.sample.find({ $and: [{ age : 54},{ legs: 2 }] })
cur.next()

Tests

npm test

In the Browser

For an example of Mongo-Local-DB in the browser check out: http://belteshazzar.github.io/mongo-local-db/index.html

Usage

Download from here: https://raw.githubusercontent.com/belteshazzar/mongo-local-db/master/mongo-local-db.js

Include in your web page:

<script src="mongo-local-db.js"></script>

Query localStorage or other collections (note that in the browser the localStorage collection is automatically created and because it is backed by HTML5 localStorage it will persist across multiple sessions):

<script>
   var db = new MongoLocal.DB()
   db.localStorage.insert({ age: 4,	legs: 0	});
   var cur = db.localStorage.find();
   alert(JSON.stringify(cur.toArray()));
</script>

API Status

The following table summarises the API implementation status.

Database Methods

NameImplemented
db.cloneCollectionno
db.cloneDatabaseno
db.commandHelpno
db.copyDatabaseno
db.createCollectionYes
db.currentOpN/A
db.dropDatabaseYes
db.evalN/A
db.fsyncLockN/A
db.fsyncUnlockN/A
db.getCollectionno
db.getCollectionInfosno
db.getCollectionNamesYes
db.getLastErrorno
db.getLastErrorObjno
db.getLogComponentsN/A
db.getMongoN/A
db.getNameno
db.getPrevErrorno
db.getProfilingLevelN/A
db.getProfilingStatusN/A
db.getReplicationInfoN/A
db.getSiblingDBN/A
db.helpYes
db.hostInfoN/A
db.isMasterN/A
db.killOpN/A
db.listCommandsN/A
db.loadServerScriptsN/A
db.printCollectionStatsN/A
db.printReplicationInfoN/A
db.printShardingStatusN/A
db.printSlaveReplicationInfoN/A
db.repairDatabaseN/A
db.resetErrorN/A
db.runCommandN/A
db.serverBuildInfoN/A
db.serverCmdLineOptsN/A
db.serverStatusN/A
db.setLogLevelN/A
db.setProfilingLevelN/A
db.shutdownServerN/A
db.statsno
db.versionno
db.upgradeCheckN/A

Collection Methods

NameImplemented
db.collection.aggregateno
db.collection.bulkWriteno
db.collection.countyes
db.collection.copyToyes
db.collection.createIndexno
db.collection.dataSizeno
db.collection.deleteOneyes
db.collection.deleteManyyes
db.collection.distinctyes
db.collection.dropyes
db.collection.dropIndexno
db.collection.dropIndexesno
db.collection.ensureIndexno
db.collection.explainno
db.collection.findyes
db.collection.findAndModifyno
db.collection.findOneyes
db.collection.findOneAndDeleteyes
db.collection.findOneAndReplaceyes
db.collection.findOneAndUpdateyes
db.collection.getIndexesno
db.collection.getShardDistributionN/A
db.collection.getShardVersionN/A
db.collection.groupno
db.collection.insertyes
db.collection.insertOneyes
db.collection.insertManyyes
db.collection.isCappedno
db.collection.mapReduceno
db.collection.reIndexno
db.collection.replaceOneyes
db.collection.removeyes
db.collection.renameCollectionno
db.collection.saveno
db.collection.statsno
db.collection.storageSizeno
db.collection.totalSizeno
db.collection.totalIndexSizeno
db.collection.updateyes
db.collection.updateOneyes
db.collection.updateManyyes
db.collection.validateno

Cursor Methods

NameImplemented
cursor.batchSizeN/A
cursor.closeN/A
cursor.commentno
cursor.countyes
cursor.explainN/A
cursor.forEachyes
cursor.hasNextyes
cursor.hintN/A
cursor.itcountno
cursor.limityes
cursor.mapyes
cursor.maxScanN/A
cursor.maxTimeMSN/A
cursor.maxno
cursor.minno
cursor.nextyes
cursor.noCursorTimeoutN/A
cursor.objsLeftInBatchN/A
cursor.prettyno
cursor.readConcernN/A
cursor.readPrefN/A
cursor.returnKeyN/A
cursor.showRecordIdN/A
cursor.sizeno
cursor.skipyes
cursor.snapshotno
cursor.sortyes
cursor.tailableno
cursor.toArrayyes
cursor.next()yes

Keywords

mongo

FAQs

Package last updated on 27 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts