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

@hamstudy/mongodb-mobile-client

v1.0.0-beta.6

Published

Client used by @hamstudy/capacitor-mongodb-mobile and potentially others

Downloads

9

Readme

Introduction

This package is intended to be a semi-generic client for MongoDB Mobile. Why does it need a client? I'm so glad you asked!

MongoDB Mobile is a fantastic tool which (as of this writing) works only on iOS and Android. This makes it one of the best options for databases on mobile platforms, but in order to use it with mobile web applications with Cordova or Capacitor you end up needing to create an interface which is just a little bit less-than-ideal.

This client was written to use with the capacitor-mongodb-mobile project; it was actually included as part of the project during early development, but we quickly realized that we'd want to be able to potentially use it with a Cordova plugin instead, or perhaps even something which could be made to work in Electron.

Installing

npm install @hamstudy/mongodb-mobile-client

If you need the capacitor mongodb mobile plugin as well (which you probably do):

npm install @hamstudy/capacitor-mongodb-mobile

Use

At present the only known way to use this is with the capacitor-mongodb-mobile capacitor plugin. Install that in your Capacitor project and then you can initialize it like so:

import { Plugins } from '@capacitor/core';
import { MongoDBMobileSource, setMongoMobilePlugin, Db, Types } from '@hamstudy/mongodb-mobile-client';

const MongoDBMobile = Plugins.MongoDBMobile as MongoDBMobileSource;
setMongoMobilePlugin(MongoDBMobile);

const dbReadyPromise = MongoDBMobile.initDb();

After that you can use the Db class as your main entrypoint:

const myDb = new Db("myDatabase");
const users = myDb.createCollection("users"); // 

From there you can query, insert, delete, etc etc etc. See the [Db interface] (https://github.com/HamStudy/mongodb-mobile-client/blob/master/src/db.ts) and the Collection interface for more information. I've tried to make this mirror the [node-native-mongodb] (http://mongodb.github.io/node-mongodb-native/3.2/) driver API as closely as I can.

Adapting to work with other database plugins

If you want this to work with another database plugin (for example a cordova plugin, etc) you just need to implement a wrapper layer which correctly implements the MongoDBMobileSource interface. While I prefer typescript it should work fine with any database interface which uses Promises and matches that interface.

Tests

If you find something that doesn't work, try writing a test to reproduce it in the Capacitor MongoDB Mobile Test App which contains our tests. We don't have complete coverage yet, so feel free to help us out by writing more to make sure your use case is supported =]

Helping out

This was created for use with our own internal projects but of course I hope it'll catch on; I'll try to be around (taxilian) on the Capacitor Slack channels if anyone would like to help; even just making the docs a little more accessible would be awesome.