react-native-upper
TypeScript icon, indicating that this package has built-in type declarations

0.1.27 • Public • Published

react-native-upper

Simple

Installation

yarn add react-native-upper

Installation dependencies

yarn add reflect-metadata react-native-quick-sqlite

Usage

import 'reflect-metadata';
import 'react-native-quick-sqlite';
import { Upper } from 'react-native-upper';
import { User } from './src/entities/user.entity';

// ...

const upper = new Upper({
    name: 'upper.sllite' // database name,
    entities: {
        User
    }
});

const users = upper.Query('User');

import { Observer } from 'react-native-upper/src/react/Observer'

const Home = () => {

    function handleUpdate(){
        users.at(0).name = "Upper name" //detect change
    }

    return (
        <View style={styles.container} >
            <Observer>
                {() => users.map(user => (
                    <Observer key={user.id}> //update some item list
                       {() => <Text>{user.name}</Text>}
                    </Observer>
                ))}
            </Observer>

            <Button title="Update name" onPress={handleUpdate} />
        </View>
    )
}

import {
  Field,
  PrimaryColumn,
  UpperEntity,
} from 'react-native-upper/src/decorators';

@UpperEntity('users')
export class User {
  @PrimaryColumn({type: 'uuid'})
  id: string;

  @Field({type: 'string'})
  name: string;
}

Contributing

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

License

MIT


Made with create-react-native-library

Package Sidebar

Install

npm i react-native-upper

Weekly Downloads

4

Version

0.1.27

License

MIT

Unpacked Size

168 kB

Total Files

237

Last publish

Collaborators

  • meedwire