Skip to content

Commit

Permalink
feat: Add Document Deletion with a Key (#150)
Browse files Browse the repository at this point in the history
This enables the deletion of a single document using their dockey.

The query will look like something like this:

mutation {
    delete_user(id: "bae-6a6482a8-24e1-5c73-a237-ca569e41507d") {
        deletedDocKey: _key
    }
}
Note: deletedDocKey is an alias of a deleted key.

This PR resolves and closes #32 and #163

Future Work:

Implement the deletion of multiple documents using multiple keys.
Implement the deletion of documents using filters.
  • Loading branch information
shahzadlone authored Feb 2, 2022
1 parent b636a9e commit 9d822c3
Show file tree
Hide file tree
Showing 10 changed files with 779 additions and 13 deletions.
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ multi-build:
start: build
./build/defradb start

.PHONY: dump
dump: build
./build/defradb client dump

.PHONY: deps\:golangci-lint
deps\:golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ${GOPATH}/bin v1.43.0
Expand All @@ -32,19 +36,26 @@ deps\:go-acc:
deps: deps\:golangci-lint deps\:go-acc
go mod download

.PHONY: tidy
tidy:
go mod tidy

.PHONY: clean
clean:
go clean cli/defradb/main.go
rm -f build/defradb

.PHONY: tidy
tidy:
go mod tidy
.PHONY: clean\:test
clean\:test:
go clean -testcache

.PHONY: test
test:
go test ./... -race

.PHONY: test\:clean
test\:clean: clean\:test test

.PHONY: test\:bench
test\:bench:
go test ./... -race -bench=.
Expand Down
11 changes: 11 additions & 0 deletions client/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,30 @@ type Collection interface {
UpdateWithKey(context.Context, key.DocKey, interface{}, ...UpdateOpt) (*UpdateResult, error)
UpdateWithKeys(context.Context, []key.DocKey, interface{}, ...UpdateOpt) (*UpdateResult, error)

DeleteWith(context.Context, interface{}, ...DeleteOpt) error
DeleteWithFilter(context.Context, interface{}, ...DeleteOpt) (*DeleteResult, error)
DeleteWithKey(context.Context, key.DocKey, ...DeleteOpt) (*DeleteResult, error)
DeleteWithKeys(context.Context, []key.DocKey, ...DeleteOpt) (*DeleteResult, error)

Get(context.Context, key.DocKey) (*document.Document, error)

WithTxn(Txn) Collection
}

type UpdateOpt struct{}
type CreateOpt struct{}
type DeleteOpt struct{}

type UpdateResult struct {
Count int64
DocKeys []string
}

type DeleteResult struct {
Count int64
DocKeys []string
}

type QueryResult struct {
Errors []interface{} `json:"errors,omitempty"`
Data interface{} `json:"data"`
Expand Down
Loading

0 comments on commit 9d822c3

Please sign in to comment.