Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection and index updates and fixes #362

Merged
merged 9 commits into from
May 27, 2020
Merged

Conversation

sanderpick
Copy link
Member

@sanderpick sanderpick commented May 27, 2020

Closes #291
Closes #359
Closes #360
Closes #361

DB

  • Adds UpdateCollection and associated API+client methods
  • Adds DeleteCollection and associated API+client methods
  • Adds GetCollectionIndexes and associated API+client methods
  • Adds dropIndex to Collection method
  • Adds index validation:
    • Index path must hit a valid type in the schema
    • Supported types: string, number, integer, boolean
    • For unique indexes, ensure collection does not contain multiple instances with the same value at path
  • Better schema validation errors

Some things to consider:

  • Updating a collection schema could cause old data to be unreadable if the particular API doesn't have access to the raw JSON results. This can happen when I field is renamed.
  • Along those lines, there's still work to do here on migrations. A migration config could go along with a collection update request, which would handle field re-mapping. Realm could be some inspiration here: Schema migrations #363
  • Back-filling / re-indexing is still not a thing: Backfill index on creation #286

Signed-off-by: Sander Pick <sanderpick@gmail.com>
Signed-off-by: Sander Pick <sanderpick@gmail.com>
@sanderpick sanderpick self-assigned this May 27, 2020
Signed-off-by: Sander Pick <sanderpick@gmail.com>
@sanderpick sanderpick force-pushed the sander/update-collections branch from 6e093f4 to 5794941 Compare May 27, 2020 18:12
Signed-off-by: Sander Pick <sanderpick@gmail.com>
Signed-off-by: Sander Pick <sanderpick@gmail.com>
@sanderpick sanderpick marked this pull request as ready for review May 27, 2020 19:38
Signed-off-by: Sander Pick <sanderpick@gmail.com>
Signed-off-by: Sander Pick <sanderpick@gmail.com>
db/collection.go Show resolved Hide resolved
db/collection.go Show resolved Hide resolved
db/collection.go Show resolved Hide resolved
db/db.go Show resolved Hide resolved
db/index.go Show resolved Hide resolved
db/index.go Show resolved Hide resolved
db/index.go Show resolved Hide resolved
db/index.go Show resolved Hide resolved
@sanderpick sanderpick requested review from jsign and carsonfarmer May 27, 2020 21:00
db/db.go Show resolved Hide resolved
Signed-off-by: Sander Pick <sanderpick@gmail.com>
Copy link
Member

@carsonfarmer carsonfarmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'm pleased to see how much of the old indexing functionality was still useful! Overall a much cleaner usage, and exposing these APIs via the clients will also help quite a bit with access from clients etc. No nits from here, very nice to see the docs updates 👍 .

api/client/client.go Show resolved Hide resolved
api/client/client_test.go Show resolved Hide resolved
db/collection_test.go Show resolved Hide resolved
db/collection_test.go Show resolved Hide resolved
db/collection_test.go Show resolved Hide resolved
db/collection_test.go Show resolved Hide resolved
db/db.go Show resolved Hide resolved
db/db.go Show resolved Hide resolved
db/index.go Show resolved Hide resolved
db/index.go Show resolved Hide resolved
Copy link
Contributor

@jsign jsign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!, left some nits/comments.

api/client/client_test.go Show resolved Hide resolved
api/service.go Outdated Show resolved Hide resolved
db/collection.go Outdated Show resolved Hide resolved
db/db.go Show resolved Hide resolved
db/db.go Outdated Show resolved Hide resolved
Signed-off-by: Sander Pick <sanderpick@gmail.com>
@sanderpick
Copy link
Member Author

Thanks for the reviews guys 🍺

@sanderpick sanderpick merged commit 907f0f0 into master May 27, 2020
@sanderpick sanderpick deleted the sander/update-collections branch May 27, 2020 23:15
dgtony pushed a commit to anyproto/go-threads that referenced this pull request Aug 24, 2020
* db: cleanup indexing, add update collection method

Signed-off-by: Sander Pick <sanderpick@gmail.com>

* db: adds delete collection, more index cleanup

Signed-off-by: Sander Pick <sanderpick@gmail.com>

* db: add update collection api method and more tests

Signed-off-by: Sander Pick <sanderpick@gmail.com>

* db: add get indexes method to api

Signed-off-by: Sander Pick <sanderpick@gmail.com>

* db: ensure unique indexes can be unique

Signed-off-by: Sander Pick <sanderpick@gmail.com>

* db: use token opt in collection methods

Signed-off-by: Sander Pick <sanderpick@gmail.com>

* db: use two locks

Signed-off-by: Sander Pick <sanderpick@gmail.com>

* db: check index path on hydration

Signed-off-by: Sander Pick <sanderpick@gmail.com>

* review: address feedback

Signed-off-by: Sander Pick <sanderpick@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants