Hello everyone,
I’ve got a question about references in smart fields. Is it possible to conditionally specify references to other collections or manage them somehow? I have a field that can be a reference to an entry in one of three possible collections.
Thank you!
const { collection } = require('forest-express-mongoose');
collection('transactions', {
fields: [
{
field: 'playerId',
type: ['String'],
// here it can be either player_collection_1, player_collection_2 or player_collection_3
reference: 'player_collection_1._id'
get: transaction => {
const { id } = transaction;
if (id) {
return id;
} else {
return '--';
}
},
},
],
}