在Document数据库中构造数据

时间:2018-02-04 16:54:51

标签: json database nosql google-cloud-firestore

我正在构建一个应用程序,它将作为某些服务的议程或计划书。计划让应用程序以“按客户”的方式工作,Angular在前端,并使用新的Google Firestore,用于所有实时和伪后端的东西。

问题是,由于我之前从未使用过NoSQL数据库,我应该如何在Firestore中构建数据?

我想到了一些看起来像这样的东西:

{
    //Collection
    "customer-a": {
        //Document
        "info": {
            "name": "Customer A",
            "Phones": [{
                "contact-name": "",
                "number": ""
            }],
            "address": {
                "type": "street",
                "name": "",
                "number": 0,
                "neighborhood": "",
                "city": "",
                "state": "",
                "zipcode": "",
                "country": "",
                "coordinates": {
                    "latitude": "",
                    "longitude": ""
                }
            }
        },
        //Document
        "config": {
            "active-theme": "",
            "themes": [{}]
        },
        //Document
        "customer-data": {
            //SubCollection
            "employees": {
                //Document
                "employee-a": {
                    "name": "",
                    "phone": "",
                    "rattings": [],
                    "address": {
                        "type": "street",
                        "name": "",
                        "number": 0,
                        "neighborhood": "",
                        "city": "",
                        "state": "",
                        "zipcode": "",
                        "country": ""
                    },
                    //SubCollection
                    "schedulings": {
                        //Document
                        "2017": {
                            "total": 300,
                            "scheduling": [{
                                "client": {
                                    "name": "",
                                    "phone": "",
                                    "rating": 5,
                                },
                                "price": 10,
                                "services": [{
                                    "name": "",
                                    "price": 10
                                }],
                                "datetime": "",
                            }]
                        },
                        "2018": {
                            "total": 300,
                            "scheduling": [{
                                "client": {
                                    "name": "",
                                    "phone": "",
                                    "classificacao": 5,
                                },
                                "price": 10,
                                "services": [{
                                    "name": "",
                                    "price": 10
                                }],
                                "datetime": "",
                            }]
                        },
                    }
                }
            },
            //SubCollection
            "stock": {}
        }
    }
}

我正在考虑将调度分成几年,因为我认为它的大小可能会增长很多,但正如我所说,我从未使用过这种数据库,所以我真的不知道有多少数据我可以在文档中嵌套,例如......

作为基础计算的夸大数据,我想到每年为每位员工存储大约200万个“对象”,是否可以存储那么多嵌套的数据? 我是否应该继续在Firestore中创建子集合,或者它应该是一个单独的集合来存储不同的文档并嵌套所有内容?

希望有人可以帮助我, 感谢。

0 个答案:

没有答案