results model:
// This model was generated by Forest CLI. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (mongoose, Mongoose) => {
// This section contains the properties of your model, mapped to your collection's properties.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const schema = Mongoose.Schema(
{
resources: { type: [Mongoose.Schema.Types.ObjectId], ref: 'resources' },
technologies: {
type: [Mongoose.Schema.Types.ObjectId],
ref: 'technologies',
},
loads: { type: [Mongoose.Schema.Types.ObjectId], ref: 'loads' },
carriers: { type: [Mongoose.Schema.Types.ObjectId], ref: 'carriers' },
lifeTime: Number,
projectID: Mongoose.Schema.Types.ObjectId,
},
{
timestamps: false,
}
)
return mongoose.model('results', schema, 'results')
}
project model in another database i want a smart relation with:
// This model was generated by Forest CLI. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (mongoose, Mongoose) => {
// This section contains the properties of your model, mapped to your collection's properties.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const schema = Mongoose.Schema({
'city': String,
'company': String,
'created_at': Date,
'configuration': {
'general': {
'lifetime': Number,
'interestRate': Number,
'kpi': {
'cpx': Object,
'opx': Object,
},
'latitude': Object,
'longitude': Object,
'inflationRate': Number,
'budget': String,
'notes': String,
'fixedOpex': String,
'fixedCapex': String,
},
'revision': Number,
'system': {
'budget': Number,
'network': {
'revision': Number,
},
},
},
'icon': String,
'street': String,
'importance_capex': Number,
'status': String,
'importance_opex': Number,
'capex': Boolean,
'interest': Number,
'electrical': Boolean,
'updated_at': Date,
'country': String,
'heating': Boolean,
'coo': Boolean,
'importance_coo': Number,
'domain': String,
'cooling': Boolean,
'lifetime': Number,
'title': String,
'discount': Number,
'email': String,
'opex': Boolean,
'author': String,
'description': String,
'user_id': Number,
'zipcode': Number,
}, {
timestamps: false,
});
return mongoose.model('projects', schema, 'projects');
};
fields array in forest/results file:
fields: [
{
field: "projectID",
type: "String",
reference: "projects._id",
isFilterable: true,
},
],
the filtration is not working as it needs a filter function but i am not quite sure how to implement this on smart relation as a sub field appears in the filter