简体   繁体   English

我们如何在 Nodejs 的 gcp firestore 数据库中以编程方式创建复合索引?

[英]How we can create compound index programmatically in gcp firestore database in Nodejs?

Firestore need compound index for a range and equal comparison together. Firestore 需要一个范围的复合索引和相等的比较。 Lets say user collection, query:让我们说用户集合,查询:

this.fireStoreDB.collection('users').where('user', 'in', [111, 222, 333]).where('timestamp' > '2019-01-01'). 

It will give link if compound index is not there to manually create that compound index via link.如果没有复合索引,它将提供链接以通过链接手动创建该复合索引。 Is there a programtic way to create same dynamically in Node or any other language?有没有一种编程方式可以在 Node 或任何其他语言中动态创建相同的内容?

This is not possible in Firestore by design.按照设计,这在 Firestore 中是不可能的。 The reason for that is because the whole idea behind indexes is that it should be part of your development flow to identify if you need any composite indexes for more complex queries.这样做的原因是因为索引背后的整个想法是,它应该成为您开发流程的一部分,以确定您是否需要任何复合索引来进行更复杂的查询。

Not to mention that if you automate it, it's very likely that you reach the limit of 200 composite indexes by database very fast.更不用说如果你自动化它,你很可能很快达到数据库 200 个复合索引的限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM