Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
feat: update BatchDeleteModel
Browse files Browse the repository at this point in the history
  • Loading branch information
YanceyOfficial committed Jan 1, 2020
1 parent e1ca6a1 commit 6553a87
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type BatchDeleteModel {
ok: Float
n: Float
deletedCount: Float
ids: [ID!]!
}

type BatchUpdateModel {
Expand Down
6 changes: 5 additions & 1 deletion src/database/models/batch-delete.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Field, ObjectType } from 'type-graphql'
import { Field, ObjectType, ID } from 'type-graphql'

@ObjectType()
export class BatchDeleteModel {
Expand All @@ -10,4 +10,8 @@ export class BatchDeleteModel {

@Field({ nullable: true })
public readonly deletedCount?: number

// FIXME: ids 不是可选参数
@Field(() => ID)
public readonly ids?: string[]
}
7 changes: 6 additions & 1 deletion src/open-sources/open-sources.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ export class OpenSourcesService {
}

public async batchDelete(ids: string[]): Promise<BatchDeleteModel> {
return this.openSourceModel.deleteMany({
const res = await this.openSourceModel.deleteMany({
_id: { $in: ids },
})

return {
...res,
ids,
}
}
}

0 comments on commit 6553a87

Please sign in to comment.