Trying to start with RxDB in my angular application. Wanted to get something simple to work:
export const LANG = {
version: 0,
title: "Language Key",
type: "object",
properties: {
key: {
type: "string",
primary: true
}
},
required: ["key"]};
RxDB.create({
name: "test",
adapter: "idb",
multiInstance: false
}).then((db) => {
if (!db["language"]) {
db.collection({
name: "language",
schema: LANG
}).then((c) => {
c.upsert({key: "de-DE"}).then(() => {
console.log("inserted")
})
})
} else {
db["language"].findOne().exec().then((res) => {
console.log("found", res)
})
}
})
My problem is, that the created collection "language" won't be found on application reload. The code always executes the if-path not the else path like I was expecting.
What I'm doing wrong here? Thx for help!