Ich habe dies:Mongoosastic Referenz nicht gespeichert
const ProjectSchema = new Schema({
projectId: String,
author: { type: Schema.Types.ObjectId, ref: 'User', es_indexed: true, es_schema: getUserModel().schema, es_select: 'first_name last_name email' },
participants: [String],
category: String,
title: String,
description: String,
});
und Benutzer sieht wie folgt aus:
const UserSchema = new Schema({
userId: String,
first_name: String,
last_name: String,
email: String,
password: String,
});
in meiner Datenbank, die ich sehe:
{
"_id" : ObjectId("58d4456fd3d52632e010d377"),
"author" : ObjectId("58ce87e7f86e5d36f6ccfb81"),
"projectId" : "J0MXYM1S872Y3",
"category" : "gaming",
"title" : "The Project",
"description" : "This is the project.",
"participants" : [ ],
"__v" : 0
}
ObjectId("58ce87e7f86e5d36f6ccfb81")
ist eine gültige ID Ich kann einen Benutzer mit dieser ID finden.
auf Elasticsearch Kopf Ich sehe dies:
"_source": {
"projectId": "J0MXYM1S872Y3",
"author": { },
"participants": [ ],
"category": "gaming",
"title": "The Project",
"description": "This is the project."
}
Warum Autor leer ist ???
EDIT
Ich habe diese am Boden:
ProjectSchema.plugin(mongoosastic, {
esClient: esClient,
populate: [
{path: 'users', select: 'first_name last_name email'}
],
});