thanks in advance
Iam using watermelon db in react native android it returns undefined for the collection.
const handleDB = async () => {
const myCollection = database.collections.get('data_items')
await database.action(async () => {
const newPost = await myCollection.create(post => {
post.ItemID = 9
post.ItemParentItem_ID = 8
})
})
}
And i call this from same Functional Component
handleDB()
Is there any work around
My DB
import { Database } from "@nozbe/watermelondb";
import SQLiteAdapter from "@nozbe/watermelondb/adapters/sqlite";
import { dbModel } from "./"
import { mySchema} from "./schema"
const adapter = new SQLiteAdapter({
dbName: 'Northel',
schema: mySchema
});
export const database = new Database({
adapter,
modelClasses: [dbModel],
actionsEnabled: true,
});
If I console log myCollection I get undefined.
i have imported the database as
import { database } from '../model/database'