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-ibm-mobilefirst-jsonstore

v8.0.2022081612

Published

React Native SDK for IBM JSONStore. Works with IBM Mobile First

Downloads

26

Readme

React Native SDK for IBM MobileFirst JSONStore

Description

The IBM Mobile Foundation JSONStore is a client-side API providing a lightweight, document-oriented storage system. JSONStore enables persistent storage of JSON documents. Documents in an application are available in JSONStore even when the device is offline. This persistent, always-available storage can be useful to give users access to documents when,for example, there is no network connection available in the device.

Key features

  • Automatic upstream or downstream synchronization of on-device data with a Cloudant database (or a database compliant with the Couch DB protocol).
  • Data indexing for efficient searching
  • Mechanism for tracking local-only changes to the stored data
  • Support for multiple users
  • AES 256 encryption of stored data provides security and confidentiality. You can segment protection by user with password-protection, in the case of more than one user on a single device.

Read more about JSONStore here.

Changelog

For details of the changes in this latest release, visit the IBM Mobile Foundation Blog.

Installation

The IBM MobileFirst™ JSONStore SDK for React Native apps is dependent on the IBM MobileFirst Foundation SDK. If you have already added the IBM MobileFirst Foundation SDK to your app, continue with the instructions below.

Navigate to the folder of your React Native app and run the following command to install the JSONStore SDK for React Native apps.

npm install react-native-ibm-mobilefirst-jsonstore --save

Getting Started

Pre-requisites

  1. Make sure you have all the pre-requisites for a React Native app covered. See the React Native Getting Started page if you're new to this whole stuff.

  2. A [Mobile Foundation instance on IBM Cloud] (https://console.bluemix.net/catalog/services/Mobile%20Foundation) OR an on-premise installation of the IBM Mobile Foundation server.

Create a React Native Project

  • The first step is to create a React Native project. Let's call our app as the JSONStoreApp. Use the React Native CLI to create a new project.

react-native init JSONStoreApp

cd JSONStoreApp

  • Install the MobileFirst Core SDK and complete the Getting Started Instructions from here.

  • Next, add the IBM MobileFirst JSONStore SDK to your app

npm install react-native-ibm-mobilefirst-jsonstore —-save

  • Link your project so that all native dependencies are added to your React Native project. This step is not required for react-native version 0.60 and above.

react-native link

  • Install Mobilefirst specific cocopods dependencies to the project.

cd ios && pod install

This step is applicable only for iOS platform.

Configure your Android App:

Add the following lines to the android section of <React-Native-Project>/android/app/build.gradle:

packagingOptions{
	exclude 'META-INF/ASL2.0'
}

Creating a JSONStore Collection

The first step in using the JSONStore API is to create a JSONStore Collection.

Import the JSONStore classes into your application. Open App.js and add the following line among the other import statements

import {WLJSONStore, JSONStoreCollection} from 'react-native-ibm-mobilefirst-jsonstore'; 

Next, create and open a collection. You can open multiple collections at once. Pass a JSONStoreInitOptions parameter for advanced options such as protecting your collection with a password, setting up sync policies etc.

var dogs = new JSONStoreCollection('dogs'); 
WLJSONStore.openCollections(['dogs']);  // Provide the name of the collection as a string. 

Adding data to a collection

Add JSON data to your collection.

	var hachi = { "name" : "Hachiko" , "breed" : "Akita" , "country" : "Japan"}; 
    dogs.addData(hachi).then( ()=> { 
      // Data was added to the collection successfully.
    }).catch ( (err) => { 
      // Error adding data. See the err object for more information on the error 
    })

Querying data from a collection

Use any of the JSONStoreCollection.find* APIs to query a collection. Use JSONStoreQueryPart and JSONStoreQuery APIs for advanced filtering and querying of JSON data.

	dogs.findAllDocuments().then( (result) => { 
       // result will have all the documents in the collection 
       // E.g. [ {"json": {"name":"Hachiko","breed":"Akita","country":"Japan"},"_id":2}]       
     }).catch((error) => {
        console.error ("Error finding docs " +  JSON.stringify(error));
     });

Closing, clearing and destroying your collection

Closing your collection will close your JSONStore collection for further access until it is opened again using the openCollections API

WLJSONStore.closeAll()

Clearing a collection will remove all documents from a collection but does not destroy it.

	dogs.clearCollection().then (()=>{
		// All documents cleared successfully
     }).catch( (err) => { 
       // An error occurred while clearing the collection. 
     })

Destroying a collection will permanently delete all data, all accessors and security artifacts. A collection once destroyed cannot be restored. All collections of the app will be destroyed.

	WLJSONStore.destroy()

Supported platforms

  • Android
  • iOS

Documentation

Copyright 2018 IBM Corp.

IBM - IBM MobileFirst Platform Foundation v8.0 license agreement

Terms of Use