insertMany

lets add getCountry functions:

Example
    
  const addMultipleCountriesValidator = () => {
    return object({
      set: object({ multiCountries: array(object()) }),
      get: coreApp.schemas.selectStruct("country", { users: 1 }),
    });
  };
  const addCountries: ActFn = async (body) => {
    const { multiCountries } = body.details.set;
      

return await countries.insertMany({ docs: multiCountries, projection: body.details.get, });

}; coreApp.acts.setAct({ schema: "country", actName: "addCountries", validator: addMultipleCountriesValidator(), fn: addCountries, });

insertMany functions accept three inputs:

The code

So this is all the code we've written so far (You can also see and download this code from here):

Return Of Example:
    
      {
        body: [
          {
            _id: 65a3cabbb7f33fd5950b92fe,
            name: Afghanistan,
            population: 15000000,
            abb: AFG
          },
          {
            _id: 65a3cabbb7f33fd5950b92ff,
            name: Iraq,
            population: 35000000,
            abb: IRQ
          },
          {
            _id: 65a3cabbb7f33fd5950b9300,
            name: Iran,
            population: 15000000,
            abb: IRI
          }
        ],
        success: true
      }