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

@yoronsoft/rn-realm

v1.0.0

Published

``` 简单封装移动端数据库 realm npm install @gaozh1024/rn-realm or yarn add @gaozh1024/rn-realm

Downloads

1

Readme

安装

简单封装移动端数据库 realm
npm install @gaozh1024/rn-realm
or
yarn add @gaozh1024/rn-realm

npm i [email protected]

npm i [email protected]

使用方法

import {database} from '@gaozh1024/rn-realm'

//  获取 UUID
database.getUUID()
//  => string

/**
 * 数据库操作,可进行增删改操作
 * @param schemaList        {DataBaseSchemaData[]}  schema 列表
 * @param params            {DataBaseParams}        当前数据库配置参数
 * @param hasTransaction    {boolean}               是否开启事务(可选参数,默认开启)
 * @return  IDataBaseOpen
 */
database.open(schemaList, params, hasTransaction);

/**
 * 数据库操作,仅可查询
 * @param schemaList        {DataBaseSchemaData[]}  schema 列表
 * @param params            {DataBaseParams}        当前数据库配置参数
 * @param hasTransaction    {boolean}               是否开启事务(默认开启)
 * @return  IDataBaseReadonly
 */
database.readonly(schemaList, params, hasTransaction);

/**
 * 创建表
 * @param   {DataBaseSchemaData}    表字段
 * @return  DataBaseSchemaData
 */
database.createSchema({
    name: '表名',
    //  字段
    properties: {
        name: {type: database.fieldType.string, default: '张三'}
    },
    //  主键
    primaryKey: '_id'
})

//  数据类型
database.fieldType
/**
 * =>
 *  bool
 *  int
 *  float
 *  double
 *  string
 *  decimal128
 *  objectId
 *  data
 *  date
 *  list
 *  linkingObjects
 *  dictionary
 *  set
 *  mixed
 *  uuid
 */

//  表 class
database.Schema(realm, hasTransaction)

示例

//  创建表
const AppInfoSchema = database.createSchema({
    name: 'AppInfo',
    properties: {
        _id: {type: database.fieldType.string, default: '1'},
        version: {type: database.fieldType.string, default: '1.0'},
        build: {type: database.fieldType.string, default: '1'},
    }
});

//  初始化版本信息
const dbParams: DataBaseParams = {
    //  数据库版本,每次更改都需要增加
    schemaVersion: 1
}

//  打开数据库
const db = database.open([AppInfoSchema], dbParams);
//  修改数据
db.schema.add(AppInfoSchema, {_id: '1', version: '1.0', build: '1'});
//  修改数据
db.schema.edit(AppInfoSchema, '1', {version: '2.0', build: '2'});
//  查看数据
db.schema.get(AppInfoSchema, '1');
//  => {_id:'1',version:'2.0',build:'2'}

//  关闭数据库
db.backClose();

/**
 * 注意:
 *  数据库执行查询操作后,需要将数据脱钩,赋值与另外一个字段输出出来,否则数据展示 undefined
 */