我对Mongoose和MongoDB很新,所以我很难搞清楚这样的事情是否可行:
Item = new Schema({
id: Schema.ObjectId,
dateCreated: { type: Date, default: Date.now },
title: { type: String, default: 'No Title' },
description: { type: String, default: 'No Description' },
tags: [ { type: Schema.ObjectId, ref: 'ItemTag' }]
});
ItemTag = new Schema({
id: Schema.ObjectId,
tagId: { type: Schema.ObjectId, ref: 'Tag' },
tagName: { type: String }
});
var query = Models.Item.find({});
query
.desc('dateCreated')
.populate('tags')
.where('tags.tagName').in(['funny', 'politics'])
.run(function(err, docs){
// docs is always empty
});
Run Code Online (Sandbox Code Playgroud)
这有更好的方法吗?
编辑
为任何困惑道歉.我要做的是获取包含有趣标签或政治标签的所有项目.
编辑
没有where子句的文件: …
我似乎无法在Dynamo db local中获得流支持,是否支持?我能找到它的唯一标志是http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.html#Tools.DynamoDBLocal.Differences中的最后一个要点.
使用dynamodb local,似乎忽略了StreamSpecification,因此在调用createTable或describeTable时没有LatestStreamArn
以下代码使用托管的dynamodb服务返回LatestStreamArn,但不返回dynamodb local:
ddb.createTable({
TableName: 'streaming_test',
AttributeDefinitions: [
{ AttributeName: 'id', AttributeType: 'S' }
],
KeySchema: [
{ AttributeName: 'id', KeyType: 'HASH' }
],
ProvisionedThroughput: {
ReadCapacityUnits: 5,
WriteCapacityUnits: 5
},
StreamSpecification: {
StreamEnabled: true,
StreamViewType: 'NEW_AND_OLD_IMAGES'
}
}, function (err, data) {
if (err) {
console.log(err, err.stack)
} else {
// data.TableDescription.StreamSpecification and
// data.TableDescription.LatestStreamArn are undefined
// for dynamodb local
console.log(data)
}
})
Run Code Online (Sandbox Code Playgroud) 我正在尝试监听自定义事件,但我希望有效地"忽略"它是命名空间或以某种方式监听所有命名空间而不单独定义它们的事实.
$('#test').on('custom', ...);
$('#test').trigger('custom.namespace1');
$('#test').trigger('custom.namespace2');
Run Code Online (Sandbox Code Playgroud)
我希望能够做到这一点的原因是因为我有多个ui插件可以在隐藏/显示事件时触发事件.这些事件主要在内部使用,但是命名空间,因此它们不会相互冲突.但是,我还想知道何时隐藏特定的ui元素,而不依赖于其执行其他清理逻辑的源.
在上面的示例中,由于触发器事件是命名空间,因此不会发生任何事情.我能听到所有名称空间的效果custom.*吗?
谢谢
编辑
即便是类似的东西也是可取的,但仍然无法让它发挥作用
$('#test').on('custom.global', log);
$('#test').trigger('custom.global.namespace1');
$('#test').trigger('custom.global.namespace2');
Run Code Online (Sandbox Code Playgroud)
我正在尝试为弹性beantalk资源创建可重用的terraform模块。我一直在努力弄清楚如何传递应用程序环境变量。我想做这样的事情:
./api.tf
module "eb" {
source = "./eb"
name = "api"
vpc_id = "${var.vpc_id}"
...
environment = {
VAR1 = "${var.var1}"
VAR2 = "${var.var2}"
VAR3 = "${var.var3}"
...
}
}
Run Code Online (Sandbox Code Playgroud)
./eb/eb.tf
variable "name" { }
variable "vpc_id" { }
variable "environment" { type = "map" }
resource "aws_elastic_beanstalk_environment" "api" {
name = "${var.name}"
...
setting {
namespace = "aws:ec2:vpc"
name = "VPCId"
value = "${var.vpc_id}"
}
# application environment variables
# Here's where I'm stuck:
# I would like to …Run Code Online (Sandbox Code Playgroud)