Open taisen opened 1 year ago
Seems to be a promise object, so tried to use await and i have following result
The code
console.log(await Parameter.createTable()); const props = { id: 1, nameParam: 'name parameter', valueParam: 'value parameter' } const param = new Parameter(props); param.save(); console.log("param save",param); let paramInDb = await Parameter.findBy({ id_eq: 1 }); console.log(".findBy({ id_eq: 1 })",paramInDb); console.log("find(1)",await Parameter.find(1)); console.log("query",await Parameter.query());
The result
LOG true LOG true LOG param save {"id": 1, "nameParam": "name parameter", "valueParam": "value parameter"} LOG .findBy({ id_eq: 1 }) null LOG find(1) null LOG query []
Can you help? Thanks, Michaël.
For a reason i don't understand if i add autoincrement: true and remove the "forced" id from the object to save, the object is correclty saved and retrieved
the following is working
const props = { nameParam: 'name parameter', valueParam: 'value parameter' }//remove the "forced" id property const param = new Parameter(props); param.save();//correctly saved! import * as SQLite from "expo-sqlite" import { BaseModel, types } from 'expo-sqlite-orm' export default class Parameter extends BaseModel { constructor(obj) { super(obj) } static get database() { return async () => SQLite.openDatabase('videothequesss.db') } static get tableName() { return 'parameters' } static get columnMapping() { return { id: { type: types.INTEGER, primary_key: true, autoincrement: true}, nameParam:{ type: types.TEXT }, valueParam: { type: types.TEXT } } }
}
Hello,
I tried to use the expo-sqlite-orm but any operation (createTable, find, findBy..) returned
can you please help?
The code
The Parameter class