
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
react-native-database
Advanced tools
npm install --save react-native-database
Requires that Realm is also installed, if not:
npm install --save realm
This library contains two components, which can be used independently or in parallel
Store any data your app needs in local storage, using essentially the same interface as standard Realm, with custom fine grained notification functionality. Requires a realm format schema to be passed in on construction.
Essentially the same as Realm, but with different notifications.
write(callback)
- Creates a transaction, and executes a function within that transaction. Essential to wrap any code making persistent changes in a write()
. See the realm docsaddListener(callback)
- The callback
passed in will be executed whenever there is a change to the database, and be passed the change type, record type, the old version of the record, and any additional parameters passed into the function that caused the change (see the ...listenerArgs
in create
, update
etc. below). addListener
returns the id of the listener, which can be used to remove it once it is no longer needed (be sure to do this, or functions could be called with their context out of scope!)removeListener(listenerId)
- Detaches the listener function identified by listenerId from the databasecreate(type, properties, ...listenerArgs)
, update(type, properties, ...listenerArgs)
, delete(type, object, ...listenerArgs)
, deleteAll(...listenerArgs)
- All work exactly as in Realm, but also send out notifications of the change, i.e. call any change listeners that are attached to this Database. Any additional parameters beyond the standard Realm ones are passed through to the listening function in the same orderobjects(type)
- Returns a ResultSet of all objects of the given type. The data is not immediately loaded into memory, meaning you don't have to worry about large queries exhausting memory capacity, or pagination to avoid it - Realm takes care of all of this, and loads the data as it is used. See the realm docsimport { Database } from 'react-native-database';
class User {};
User.schema = {
name: 'User',
primaryKey: 'id',
properties: {
id: 'string',
username: { type: 'string', default: 'placeholderUsername' },
lastLogin: { type: 'date', optional: true },
firstName: { type: 'string', optional: true },
lastName: { type: 'string', optional: true },
email: { type: 'string', optional: true },
},
};
const schema = { schema: [User], schemaVersion: 1 };
const database = new Database(schema);
Settings can be constructed with no parameters, if you only intend to store settings in the local Realm database, and no extra data.
const settings = new Settings(database);
settings.set('CurrentUserName', 'Edwin');
console.log(`Hello ${settings.get('CurrentUserName')}!`); // Will print 'Hello Edwin!'
If you need to store extra data, pass through a realm database including a 'Setting' table on construction. Note that this could be a react-native-database Database rather than a raw realm database.
import { Database, Settings } from 'react-native-database';
class Setting {};
Setting.schema = {
name: 'Setting',
primaryKey: 'key',
properties: {
key: 'string',
value: 'string',
},
};
class User {};
User.schema = {
name: 'User',
primaryKey: 'id',
properties: {
id: 'string',
username: { type: 'string', default: 'placeholderUsername' },
lastLogin: { type: 'date', optional: true },
firstName: { type: 'string', optional: true },
lastName: { type: 'string', optional: true },
email: { type: 'string', optional: true },
},
};
const schema = { schema: [Setting, User], schemaVersion: 1 };
const database = new Database(schema);
const settings = new Settings(database);
database.write(() => { database.create('User', { id: '54321', username: 'edmofro', firstName: 'Edwin' }) });
settings.set('CurrentUserId', '54321');
const currentUserId = settings.get('CurrentUserId')```
console.log(`Hello ${database.objects('User').filter(`id = ${settings.get('CurrentUserId')}`)[0].firstName}!`); // Will print 'Hello Edwin!'
FAQs
A nicer interface for the react native flavour of realm
The npm package react-native-database receives a total of 2,316 weekly downloads. As such, react-native-database popularity was classified as popular.
We found that react-native-database demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.