将默认排序规则添加到现有的 mongodb 集合 [英] Add default collation to existing mongodb collection

查看:63
本文介绍了将默认排序规则添加到现有的 mongodb 集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向我的 mongodb 集合添加默认排序规则.使用排序规则创建新集合很简单:

I'm trying to add a default collation to my mongodb collections. It's simple to create a new collection with a collation:

db.createCollection(name, {collation:{locale:"en",strength:1}})

不幸的是,我浏览了文档并没有看到任何 db.updateCollection 函数.我应该如何在不破坏和重新创建新集合中的所有文档的情况下添加排序规则?

Unfortunately I looked through the docs and didn't see any db.updateCollection function. How am I supposed to add a collation without destroying and recreating all my documents in a new collection?

推荐答案

来自 整理 规范,

服务器 3.4 版本初始发布后,很多用户会想要将排序规则应用于现有集合上的所有操作.这样的用户必须为每个操作提供 Collat​​ion 选项明确地;然而,最终希望使用的大多数用户集合上所有操作的排序规则将创建一个集合使用服务器端默认值.我们现在选择偏爱用户冗长为了短期收益而过度抽象特征.

After the initial release of server version 3.4, many users will want to apply Collations to all operations on an existing collection. Such users will have to supply the Collation option to each operation explicitly; however, eventually the majority of users wishing to use Collations on all operations on a collection will create a collection with a server-side default. We chose to favor user verbosity right now over abstracting the feature for short-term gains.

所以你知道这还不是一个选择.

So you know its not a option just yet.

这篇关于将默认排序规则添加到现有的 mongodb 集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆