Giter Club home page Giter Club logo

rn-sequelize's Introduction

Sequelize

npm version Travis Build Status Appveyor Build Status npm downloads codecov Last commit Merged PRs GitHub stars Slack Status node License semantic-release

This port to use with react native and expo.

NOTE: compatible with web but replace dialectModule: SQLite with dialectModule: window, and websql API in browser is limited (check TODO), catch all queries

TODO

  • In web use sql.js

Contributing

  • Open Source!

Example

import React, { useEffect } from "react";
import { StyleSheet, Text, View, Platform } from "react-native";
import * as SQLite from "expo-sqlite";
import Sequelize from "rn-sequelize";
const Op = Sequelize.Op;
const Model = Sequelize.Model;

const sequelize = new Sequelize({
  dialectModule: SQLite,
  database: "mydb",
  dialectOptions: {
    version: "1.0",
    description: "Test DB"
    //size: 2 * 1024 * 1024
  }
});

class User extends Model {}
User.init(
  {
    name: Sequelize.STRING,
    email: Sequelize.STRING
  },
  {
    sequelize,
    modelName: "user"
  }
);
export default function App() {
  useEffect(() => {
    async function init() {
      try {
        await sequelize.sync({
          //force: true
        });

        await User.create({
          name: "Mike",
          email: "[email protected]"
        }).then(console.log);
      } catch (error) {
        console.log(error);
      }
    }
    init();
  }, []);

  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center"
  }
});

Thanks to Sequelize

Sequelize

Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server. It features solid transaction support, relations, eager and lazy loading, read replication and more.

Sequelize follows SEMVER. Supports Node v6 and above to use ES6 features.

New to Sequelize? Take a look at the Tutorials and Guides. You might also be interested in the API Reference.

Table of Contents

Installation

$ npm install --save sequelize # This will install v5

# And one of the following:
$ npm install --save pg pg-hstore # Postgres
$ npm install --save mysql2
$ npm install --save mariadb
$ npm install --save sqlite3
$ npm install --save tedious # Microsoft SQL Server

Documentation

Responsible disclosure

If you have security issues to report please refer to our Responsible Disclosure Policy for more details.

Resources

Tools

Learning

Translations

rn-sequelize's People

Contributors

msvargas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rn-sequelize's Issues

problem with close connections

[TypeError: _this2.connections[connection].close is not a function. (In '_this2.connections[connection].close(callback)', '_this2.connections[connection].close' is undefined)]

Using storage

How do I load a database in rn-sequelize? I know that in Sequelize I can use "storage: path" when initializing Sequelize, but in rn-sequelize that line seems to be ignored. What to use instead?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.