使用 mongoDB 3.4.3 我在尝试创建带有排序规则的索引时遇到了这个问题(https://jira.mongodb.org/browse/SERVER-26556)中描述的问题。
由于我已经从以前的版本升级,它说需要的是明确允许向后不兼容的 3.4 功能集,但是对于具有角色的用户,userAdminAnyDatabase我仍然没有权限:
> db.adminCommand({setFeatureCompatibilityVersion: "3.4"})
{
"ok" : 0,
"errmsg" : "not authorized on admin to execute command {setFeatureCompatibilityVersion: \"3.4\" }",
"code" : 13,
"codeName" : "Unauthorized"
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,用户需要什么角色才能做到这一点?
我目前正在学习python eve框架和mongoDB数据库,以进行宁静的API开发.在前夕,只有通过在settings.py文件中定义模式才能完成基本的CRUD操作.客户端可以发送GET/POST方法,并根据预定义的模式将数据自动存储到mongoDB中.
如果我想在将数据插入mongoDB之前对其进行预处理(例如:客户端仅发送产品数量和价格,然后服务器计算总数量并将产品,价格和数量存储到数据库中),该怎么办?如果我想在响应客户端之前处理我的数据,该怎么办?我们应该使用烧瓶控制器方法(如此EVE - 定义自定义烧瓶控制器)并手动将数据存储到数据库中吗?
我的设置有使用 TLS 和用户/密码身份验证的 mosquitto 1.4.12,它在 Ubuntu 14.04 下工作了很长一段时间没有问题。
问题是没有数据被发布到任何$SYS代理状态主题。我已经查看了配置并sys_interval设置为 10。是否还需要其他任何操作才能使其正常工作?
我已经尝试了很多客户端(mosquitto_sub、paho-mqtt、mqtt.fx),所以它看起来像是一个错误的 mosquitto 配置,而不是客户端问题。
mosquitto.conf 看起来像这样:
sys_interval 10
max_queued_messages 10000
max_inflight_messages 100
max_connections -1
connection_messages true
log_dest stderr
log_type error
log_type warning
log_type notice
log_type information
log_type all
log_timestamp true
password_file /etc/mosquitto/conf.d/jp.pw
acl_file /etc/mosquitto/conf.d/acl.conf
persistence true
persistence_location /var/lib/mosquitto/
persistence_file mosquitto.db
persistent_client_expiration 1m
autosave_interval 600
retained_persistence true
listener 8883
tls_version tlsv1.2
cafile /etc/mosquitto/ca_certificates/ca.crt
certfile /etc/mosquitto/ca_certificates/cert.crt
keyfile /etc/mosquitto/ca_certificates/cert.key
require_certificate false
allow_anonymous false
Run Code Online (Sandbox Code Playgroud)
acl.conf 有这个,可能是不必要的:
user test
topic #
Run Code Online (Sandbox Code Playgroud) 是否可以为具有奇数大小的数组的文档构建查询过滤器而不是这个?
db.records.find({'$or': [{'my_array': {'$size': 1}},
{'my_array': {'$size': 3}},
{'my_array': {'$size': 5}},
...
{'my_array': {'$size': 15}}]}))
Run Code Online (Sandbox Code Playgroud)
如果您停在某个数量上,过滤器可能无法捕获所有项目。
我正在使用Python-Eve开发API,我需要使用Cerberus创建一个MongoDB模式声明来表达如下文档:
{
name : 'John Smith',
type: 'home',
devices : [
ObjectID('1234'),
ObjectID('ABCD'),
ObjectID('D2AF'),
],
}
Run Code Online (Sandbox Code Playgroud)
我想知道如何声明Cerberus模式具有一个数组ObjectID,如devices上面的键。
我想要一个对其他文档的引用数组的架构,并且可能使它们可嵌入,就像下面的单元素架构示例(取自Python-Eve 文档):
{
'author': {
'type': 'objectid',
'data_relation': {
'resource': 'users',
'field': '_id',
'embeddable': True
},
},
}
Run Code Online (Sandbox Code Playgroud)
我怀疑这将需要自定义类型,但我仍然没有弄清楚该如何做。