I'm currently only using Joi to validate and building schemas. However I feel like I'm missing features like reference another schema like Mongoose does.
Or is the only way to do this by using both (or mongoose only)?
I want to use something similar to this:
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const personSchema = Schema({
_id: Schema.Types.ObjectId,
name: String,
age: Number,
stories: [{ type: Schema.Types.ObjectId, ref: 'Story' }]
});
const storySchema = Schema({
author: { type: Schema.Types.ObjectId, ref: 'Person' },
title: String,
fans: [{ type: Schema.Types.ObjectId, ref: 'Person' }]
});
const Story = mongoose.model('Story', storySchema);
const Person = mongoose.model('Person', personSchema);
But in Joi instead. I cannot find anything in the Documentation for Joi.
来源:https://stackoverflow.com/questions/54254097/are-there-ways-to-populate-a-schema-in-joi-from-another-schema-like-mongoose-do