16 lines
439 B
TypeScript
16 lines
439 B
TypeScript
import { StringSchemaDefinition } from 'mongoose';
|
|
import { Auth, Strategy } from '..';
|
|
|
|
export const deleteStrategy = async (id: StringSchemaDefinition) => {
|
|
const strategy = await Strategy.findById(id);
|
|
|
|
if (strategy) {
|
|
const parentId = strategy.parent;
|
|
await strategy.deleteOne();
|
|
await Auth.findOneAndUpdate({ id: parentId, strategies: { $pull: id } });
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|