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

react-native-flipper-databases

v2.5.1

Published

Flipper Databases plugin for React Native

Downloads

1,784

Readme

react-native-flipper-databases

Flipper Databases plugin for React Native

license Language grade: JavaScript

NPM version NPM downloads

This React Native plugin allows browsing popular React Native databases using Flipper built-in Databases plugin.

screenshot.jpeg

Installation

yarn add -D react-native-flipper react-native-flipper-databases

Setup

iOS

No particular setup is required on iOS.

Android

Since Android already provide a built-in Databases plugin (see official docs here for more details) in order to avoid conflicts with react-native-flipper-databases it must be disabled.

Edit ReactNativeFlipper.java file under android/app/src/debug/java/<your-app-package> like this

...

import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
// import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; // <- Exclude to avoid plugin conflicts
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
...

  public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
    if (FlipperUtils.shouldEnableFlipper(context)) {
      final FlipperClient client = AndroidFlipperClient.getInstance(context);

      client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
      client.addPlugin(new ReactFlipperPlugin());
      // client.addPlugin(new DatabasesFlipperPlugin(context)); // <- Exclude to avoid plugin conflicts
      client.addPlugin(new SharedPreferencesFlipperPlugin(context));
      client.addPlugin(CrashReporterPlugin.getInstance());
...

See facebook/flipper#1628 for more details.

Expo

When sticking to a managed Expo project, it's impossible to make the necessary modifications to the ReactNativeFlipper.java file.

@liamdawson wrote a basic plugin to automate those changes, which will ensure Expo prebuild and builds via EAS will disable the integrated Databases plugin on Android.

See @liamdawson/disable-react-native-flipper-databases-expo-plugin for more info.

Usage

WatermelonDB

Compatibility

| WatermelonDB Version | Use Version | | -------------------- | ----------- | | >=0.24.0 | 2.x | | <0.24.0 | 1.x |

Setup

Attach a WatermelonDB database:

// ...

/// ReactNativeFlipperDatabases - START

if (__DEV__) {
  // Import connectDatabases function and required DBDrivers
  const { connectDatabases, WatermelonDB } = require('react-native-flipper-databases');

  connectDatabases([
    new WatermelonDB(database), // Pass in database definition
  ]);
}

/// ReactNativeFlipperDatabases - END

// ...

MongoDB Realm

Setup

Attach an open Realm:

// ...

const realm = await Realm.open(config);

/// FlipperDatabasesPlugin - START

if (__DEV__) {
  // Import connectDatabases function and required DBDrivers
  const { connectDatabases, RealmDB } = require('react-native-flipper-databases');

  connectDatabases([
    new RealmDB('Realm', realm), // Pass in a realm name and an open realm reference
  ]);
}

/// FlipperDatabasesPlugin - END

// ...

PouchDB

Setup

Attach an open PouchDB database:

// ...

const db = new PouchDB('db', {
  adapter: 'react-native-sqlite',
});

/// ReactNativeFlipperDatabases - START

if (__DEV__) {
  // Import connectDatabases function and required DBDrivers
  const {
    connectDatabases,
    PouchDB: PouchDBDriver,
  } = require('react-native-flipper-databases');

  connectDatabases([
    new PouchDBDriver([db]), // Pass in database definitions
  ]);
}

/// ReactNativeFlipperDatabases - END

// ...

Vasern

Setup

Attach an open Vasern database:

// ...

export const VasernDB = new Vasern({
  // Vasern config
});

/// ReactNativeFlipperDatabases - START

if (__DEV__) {
  // Import connectDatabases function and required DBDrivers
  const {
    connectDatabases,
    VasernDB: VasernDBDriver,
  } = require('react-native-flipper-databases');

  connectDatabases([
    new VasernDBDriver(VasernDB), // Pass in database definitions
  ]);
}

/// ReactNativeFlipperDatabases - END

// ...

react-native-sqlite-storage

Setup

Attach an open SQLite database (with Promise support enabled)

// ...

SQLite.enablePromise(true);

async function openDatabase() {
  const db = await SQLite.openDatabase({ name: 'data.db' });

  // Create tables

  /// ReactNativeFlipperDatabases - START

  if (__DEV__) {
    // Import connectDatabases function and required DBDrivers
    const { connectDatabases, SQLiteStorage } = require('react-native-flipper-databases');
    connectDatabases([
      // Pass in database definitions
      new SQLiteStorage([
        {
          name: 'data.db',
          database: db,
        },
      ]),
    ]);
  }

  /// ReactNativeFlipperDatabases - END

  return db;
}

// ...

react-native-quick-sqlite

Setup

import { openDatabase } from 'react-native-quick-sqlite'

// ...

/// ReactNativeFlipperDatabases - START

if (__DEV__) {
  // Import connectDatabases function and required DBDrivers
  const {
    connectDatabases,
    QuickSQLiteStorage,
  } = require('react-native-flipper-databases');

  openDatabase(
    { name: 'data.db' },
    (db) => {
      connectDatabases([
        new QuickSQLiteStorage([
          {
            name: 'data.db',
            database: db,
          },
        ]),
      ])
    },
    () => {},
  )
}

/// ReactNativeFlipperDatabases - END

// ...

Examples

To see how to implement this plugin and test how it works some examples are provided.

To run the examples:

  • clone the repo
git clone https://codeberg.org/panz3r/react-native-flipper-databases.git
  • bootstrap the project
yarn bootstrap
  • launch one of the following scripts from the root folder

    • example:watermelon to launch the WatermelonDB example app
    • example:realm to launch the MongoDB Realm example app
    • example:pouch to launch the PouchDB example app
    • example:vasern to launch the Vasern example app
    • example:sqlitestorage to launch the SQLite Storage example app

The plugin integrations are located inside the src/infrastructure/database folder of each example app.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with :sparkles: & :heart: by Mattia Panzeri and contributors