对此需要快速帮助。在我的生命中,我无法弄清为什么MongoDB无法对集合进行分片,指出给定的分片键为空值。
我正在尝试基于文档中的第一个标签元素创建分片,因此关键是标签[0]。为了澄清,在这种情况下,我要指向的值是“ fc4f03a4-0f7b-5cf4-af4e-8b38377a9e34”。
productList: any;
discountPercent = 0;
ngOnInit() {
this.productsService.getProducts()
.then((response:Response) => {
console.log(response);
this.productList = response;
this.discountPercent = this.productList.Discount;
})
.catch(err => console.log(err));
}
很显然,标签[0]不为null。为什么MongoDB会这样?
答案 0 :(得分:0)
将其更改为点表示法是可行的。
mongos> sh.shardCollection(“ mydb.logs”,{“ tags.0”:1});
我仍然不确定为什么它不接受第一个符号[]。