0

尝试在我的 Angular 应用程序中从 RxDB 开始。想要一些简单的工作:

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)
            })
        }
    })

我的问题是,在应用程序重新加载时找不到创建的集合“语言”。代码总是执行 if 路径而不是我期望的 else 路径。

我在这里做错了什么?谢谢帮助!

4

1 回答 1

0

您必须在每次重新启动应用程序时调用 collection() 方法。RxCollection 实例不会自动创建。

于 2019-08-22T22:26:17.480 回答