deleteOne

delete country

lets add deleteCountry functions:

Example
    
  const deleteCountryValidator = () => {
        return object({
            set: object({
            _id: string(),
            }),
            get: coreApp.schemas.selectStruct("country", 1),
        });
    };
    const deleteCountry: ActFn = async (body) => {
        const {
            set: { _id },
            get,
        } = body.details;
        

return await countries.deleteOne({ filter: { _id: new ObjectId(_id) }, hardCascade: true, });

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

deleteOne functions accept three inputs:

  • filter which is mongodb deleteOne query operation
  • and optional option which is mongodb findOption
  • ‍‍‍‍‍‍‍‍hardCascade : If it is correct, all the documents related to ind will be deleted, and if it is not, it will lead to an error

You can also read mongodb deleteOne section for more information.

Return Of Example:
    
        {
            body: true,
            success: true
        }