npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@digitaltpm/cordova-mongodb-storage-tpm

v0.0.2

Published

This plugin provides a mongodb local storage option to Cordova based applications.

Downloads

8

Readme

npm npm Travis (.org) branch

cordova-mongodb-storage-tpm

This is an update of https://github.com/mikakrooswijk/cordova-mongodb-storage

This is a Cordova plugin that exposes the functionality of MongoDB Mobile to a Cordova Android or iOS app for local storage.

NPM

Install

To install this plugin run cordova plugin add cordova-mongodb-storage-tpm in your projects root folder.

Android

  • Update defaultMinSdkVersion in the build.gradle file to 21 instead of the standard 19.

iOS

  • Run pod install in iOS folder of your project. For more information on cocoapods please look here.
  • Be sure to set the Deployment Target to at least iOS 11.0 in your .xcodeproj file.

Functionality

This is the functionality the plugin provides right now, it is limited but provides the basic CRUD functionality. More will be added in the future.


initiate(app-id: string) -> boolean

This function has to be called before doing anything else with the plugin. app-id the id of this app.

returns true if the initiation was successful, false if it failed.

window.plugins.mongodb.initiate("appId")
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});

insertOne(database: string, collection: string, document: JSONObject) -> Promise<JSONObject | boolean>

API reference for insertOne

database the database that is to be queried. collection the collection that is to be queried document a JSON object that is to be inserted into the database.

returns A promsie that resolves to a JSONArray containing the inserted document, false if the insert failed.

Example usage:

window.plugins.mongodb.insertOne('exampleDatabase', 'exampleCollection', {"exampleKey": "exampleValue"})
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});

insertMany(database: string, collection: string, documents: JSONArray) -> Promise<JSONArray>

API reference for insertMany

database the database that is to be queried. collection the collection that is to be queried documents a JSON array that are to be inserted into the database.

returns A promsie that resolves to a JSONArray containing the inserted documents.

Example usage:

window.plugins.mongodb.insertMany('exampleDatabase', 'exampleCollection', [{"exampleKey": "exampleValue"}, {"exampleKey2": "exampleValue2"}])
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});

findOne(database: string, collection: string, filter: JSONObject) -> Promise<JSONObject | boolean>

API reference for findOne

database the database that is to be queried. collection the collection that is to be queried filter a JSON object that provides the filter for the query.

returns A promsie that resolves to a JSONObject containing the first document that was found matching the filter, or false if there was no document found matching the filter.

Example usage:

window.plugins.mongodb.findOne('exampleDatabase', 'exampleCollection', {"exampleKey": "exampleValue"})
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});

replaceOne(database: string, collection: string, filter: JSONObject, update: JSONObject) -> Promise<JSONObject>

API reference for replaceOne

database the database that is to be queried. collection the collection that is to be queried filter a JSON object that provides the filter for the replace. update the object that is to be updates or inserted. returns A promsie that resolves with the object replaced.

! upsert is set to true for this function.

Example usage:

window.plugins.mongodb.replaceOne('exampleDatabase', 'exampleCollection', {"exampleKey": "exampleValue"}, {"exampleKey": "newExampleValue"})
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});

updateOne(database: string, collection: string, filter: JSONObject, update: JSONObject) -> Promise<boolean>

API reference for updateOne

database the database that is to be queried. collection the collection that is to be queried filter a JSON object that provides the filter for the update. update the update to be made. returns A promsie that resolves to totrue when the update was successful, and to false when it failed.

In the update object be sure to use the Update operators, such as $set and $rename

Example usage:

window.plugins.mongodb.updateOne('exampleDatabase', 'exampleCollection', {"exampleKey": "exampleValue"}, {$set: {"exampleKey": "newExampleValue"}})
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});

updateMany(database: string, collection: string, filter: JSONObject, update: JSONObject) -> Promise<boolean>

API reference for updateMany

database the database that is to be queried. collection the collection that is to be queried filter a JSON object that provides the filter for the update. update the updates to be made returns A promsie that resolves to totrue when the update was successful, and to false when it failed.

In the update object be sure to use the Update operators, such as $set and $rename

Example usage:

window.plugins.mongodb.updateMany('exampleDatabase', 'exampleCollection', {"exampleKey": "exampleValue"}, {$set: {"exampleKey": "newExampleValue"}})
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});

findAll(database: string, collection: string) -> romise<JSONArray>

API reference for find

Returns all the entries is a given database and collection. database the database that is to be queried. collection the collection that is to be queried returns A promsie that resolves to a JSONArray with all the documents in the specified database and collection.

window.plugins.mongodb.findAll('exampleDatabase', 'exampleCollection')
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});

find(database: string, collection: string, filter: JSONObject, order: JSONObject, skip: int, limit: int) -> Promise<JSONArray>

API reference for find

database the database that is to be queried. collection the collection that is to be queried filter a JSON object that provides the filter for the query. order a JSON object that provides the order for the query. (1 -> Ascending, -1 -> Descending) (OPTIONAL) skip a int that provides the number of skip. (OPTIONAL) limit a int that provides the number of limit. (OPTIONAL)

returns A promsie that resolves to a JSONArray containing the documents that was found matching the filter.

Example usage:

window.plugins.mongodb.find('exampleDatabase', 'exampleCollection', {"exampleKey": "exampleValue"}, {"exampleKey": 1}, 5, 10)
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});

count(database: string, collection: string, filter: JSONObject) -> Promise<long>

API reference for count

database the database that is to be queried. collection the collection that is to be queried filter a JSON object that provides the filter for the query.

returns A promsie that resolves to a long with the number of records.

Example usage:

window.plugins.mongodb.count('exampleDatabase', 'exampleCollection', {"exampleKey": "exampleValue"})
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});

deleteOne(database: string, filter: string, filter: JSONObject) -> Promise<boolean>

API reference for deleteOne

database the database that is to be queried. collection the collection that is to be queried filter the filter for the document to be deleted

returns A promise that resolves to a boolean, true if the document was deleted, false if there was no document found matching the filter.

window.plugins.mongodb.deleteOne('exampleDatabase', 'exampleCollection', {"exampleKey": "exampleValue"})
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});

deleteMany(database: string, filter: string, filter: JSONObject) -> Promise<boolean>

API reference for deleteMany

database the database that is to be queried. collection the collection that is to be queried filter the filter for the documents to be deleted

returns A promise that resolves to a boolean, true if the documents was deleted, false if there was no documents found matching the filter.

window.plugins.mongodb.deleteOne('exampleDatabase', 'exampleCollection', {"exampleKey": "exampleValue"})
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});

deleteAll(database: string, collection: string) -> Promise<boolean>

database the database that is to be queried. collection the collection that is to be removed

returns A promsie that resolves to totrue when the update was successful, and to false when it failed.

window.plugins.mongodb.deleteAll('exampleDatabase', 'exampleCollection')
.then((result) => {
    console.log(result);
})
.catch((error) => {
    console.error(error);
});