我创建了一个“品牌”集合,然后collation: { locale: "en", strength: 2}在“标题”字段上添加了一个索引。但是当我尝试使用此排序规则查询它时,它无法按预期工作:
const query = brand => mongodb.db("my-db").collection("brands")
.aggregate([
{ $match: { title: brand } },
{ $project: { _id: 0, total: 1, categories: { $slice: [ "$categories", 5 ] }, tags: { $slice: [ "$tags", 5 ] } } }
], { collation: { locale: 'en', strength: 2 } })
.asArray();
Run Code Online (Sandbox Code Playgroud)
所以调用brand('Test')会给出结果,但brand('test')给出一个空列表。
当我使用 Atlas Aggregation Builder 尝试相同的查询时,两个查询都会给出相同的(非空)结果。有任何想法吗?
有没有办法在Spring中将空列表设置为属性的默认值,如下所示:
@Value("${my.list.of.strings :" + new ArrayList<>() + "}")
private List<String> myList;
Run Code Online (Sandbox Code Playgroud)
显然不是新的ArrayList,但我需要一个空列表.
我正在为用户更改选项卡时构建一个确认对话框。该代码工作正常,但tslint抱怨类型不匹配。控制器看起来像:
export class MyController implements ng.IController {
constructor(private $transitions: TransitionService,
private $translate: angular.translate.ITranslateService) {
'ngInject';
$transitions.onStart({}, () =>
this.alert
.showConfirm(
this.$translate.instant('dialogs.confirmLeave.content'),
this.$translate.instant('dialogs.confirmLeave.title')
)
.then(() => true)
.catch(() => false)
);
}
...
}
Run Code Online (Sandbox Code Playgroud)
this.alert.showConfirmthis.$uibModal.open()最终从 angular-ui-bootstrap调用。这会给出以下警告:
error TS2345: Argument of type '() => IPromise<boolean>' is not assignable to parameter of type 'TransitionHookFn'.
Type 'IPromise<boolean>' is not assignable to type 'boolean | void | TargetState | Promise<boolean | void | TargetState>'.
Type 'IPromise<boolean>' is not assignable to type …Run Code Online (Sandbox Code Playgroud)