addRelation

lets add addRelation functions:

Example
    
const addCityCountryValidator = () => {
  return object({
    set: object({
      city: objectIdValidation,
      country: objectIdValidation,
      isCapital: boolean(),
    }),
    get: coreApp.schemas.selectStruct("city", 1),
  });
};

const addCityCountry: ActFn = async (body) => { const { country, city, isCapital } = body.details.set;

return await cities.addRelation({ filters: { _id: new ObjectId(city) }, projection: body.details.get, relations: { country: { _ids: new ObjectId(country), relatedRelations: { citiesAsc: true, citiesDesc: true, citiesByPopAsc: true, citiesByPopDesc: true, capitalCity: isCapital, }, }, }, replace: true, });

}; coreApp.acts.setAct({ schema: "city", actName: "addCityCountry", validator: addCityCountryValidator(), fn: addCityCountry, });

addRelations functions accept three inputs:

Return Of Example:
    
    {
      body: {
        _id: 65a3dfe5b7f33fd5950b9345,
        name: Harat,
        population: 1800000,
        abb: HAR,
        country: {
          _id: 65a3dfe5b7f33fd5950b9342,
          name: Afghanistan,
          population: 15000000,
          abb: AFG
        }
      },
      success: true
    }