これは私のデータ構造です。リレーショナル クエリを実装したいのですが、クエリはネストされたデータ フィールドです。マングース ドキュメントを読んだ後、ネストされたクエリの基本的な使用法を知っていますが、テストしても何も返されませんでした。助けてください。ありがたい。
//Define
var TimeLine = new keystone.List('TimeLine', {
hidden:true
});
TimeLine.add({
article:{type:Types.Relationship,ref:'Post'}
});
var Post = new keystone.List('Post', {
map: { name: 'title' },
autokey: { path: 'slug', from: 'title', unique: true }
});
Post.add({
title: { type: String, required: true },
state: { type: Types.Select, options: 'draft, published, archived', default: 'draft', index: true },
author: { type: Types.Relationship, ref: 'User', index: true },
publishedDate: { type: Types.Date, index: true, dependsOn: { state: 'published' } },
image: { type: Types.CloudinaryImage },
content: {
brief: { type: Types.Html, wysiwyg: true, height: 150 },
extended: { type: Types.Html, wysiwyg: true, height: 400 }
}
});
//Usage
var timeline = keystone.list('TimeLine').model;
timeline.find({
"article.title":"xxxxxxxxx"//Here is a nested query
}).populate('article').exec(function (err, result) {
console.log(err,result);//This is the query results, but it can not return anything.
});
//nothing return!!!