Closed DennisStudent closed 5 years ago
I put the Animal.js in a subfolder "entity" and get the warning: "Possible Unhandled Promise Rejection (id: 0): Object {}".
./entity/Animal.js
import { SQLite } from 'expo' import { BaseModel, types } from 'expo-sqlite-orm' export default class Animal extends BaseModel { constructor(obj) { super(obj) } static database() { return Promise.resolve(SQLite.openDatabase('database.db')) } static get tableName() { return 'animals' } static get columnMapping() { return { id: { type: types.INTEGER, primary_key: true }, name: { type: types.TEXT, not_null: true }, color: { type: types.TEXT }, age: { type: types.NUMERIC }, another_uid: { type: types.INTEGER, unique: true }, timestamp: { type: types.INTEGER, default: () => Date.now() } } } }
App.js
import React from 'react'; import { View } from 'react-native'; import Animal from './entity/Animal'; export default class App extends React.Component { async componentDidMount() { await Animal.createTable(); await Animal.create({ id: 1, name: '', color: 'Brown', age: 2 }); const createdAnimal = await Animal.find(1); console.log(createdAnimal); } render() { return ( <View /> ); } }
return Promise.resolve(SQLite.openDatabase('../database.db'))
worked.
I put the Animal.js in a subfolder "entity" and get the warning: "Possible Unhandled Promise Rejection (id: 0): Object {}".
./entity/Animal.js
App.js