Socket
Book a DemoInstallSign in
Socket

dexie-mongoify

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dexie-mongoify

Dexie.js plugin with MongoDB-like API

latest
Source
npmnpm
Version
1.3.0
Version published
Maintainers
2
Created
Source

Mongoify

Codeship CI status Deps

Mongoify is an addon for Dexie.js, IndexedDB wrapper.

Mongoify tries to provide MongoDB-like* query language and API, but uses promises instead of callbacks.

* MongoDB-like means that Mongoify tries to follow MongoDB where it makes sense, to simplify API and implementation. You are welcome to send PR that increases MongoDB compatibility.

API documentation

Examples:

You need to open database first:


var db = new Dexie('Database');
db.version(1).stores({ people: '++id, firstname, lastname, age' });
db.open();
// Thanks to Dexie, there is not need to wait for database to open,
// you can start working right away

Then you can start inserting objects:


var person = { firstname: 'John', lastname: 'Doe', age: 30 };
db.collection('people').insert(person).then(function() {

    // John is in db now :)

});

Querying database:

Get all objects:


db.collection('people').find({}).toArray().then(function(people) {
    // empty query returns all objects
});

Get objects by simple field match:


db.collection('people').find({ age: 30 }).toArray().then(function(people) {
    // people 30 years old
});

You can also use some of the MongoDB query operators:


db.collection('people').find({ age: { $gte: 23 } }).toArray().then(function(people) {
    // people that are 23 and more years old
});

Updating objects:

db.collection('people').update({ lastname: 'Doe' }, { age: 10 }).then(function(updatesCount) {
    // all Does are 10 years old now
});

Using update operators:



db.collection('people').findOne({ skills: { $in: ['html', 'javascript'] }  }, updates).then(function(person) {

    return db.collection('people').update(person, { $push: { skills: 'jquery' } });

}).then(function(updatesCount) {
    // person has jquery skills now
});

And more

License

MIT © Yury Solovyov

Keywords

mongo

FAQs

Package last updated on 04 Apr 2018

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.