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

Add filter args to document fields #10

Closed
wants to merge 2 commits into from
Closed

Conversation

sgwilym
Copy link
Collaborator

@sgwilym sgwilym commented Aug 4, 2020

Adds filtering to document fields, so you can write queries like this:

{
  workspaces {
    documents(pathPrefix: "/wiki") {
      ... on ES3Document {
        path
      }
    }
  }
}

Also supports the versionsByAuthor arg. Will be easy to add more QueryOpts from earthstar as they are implemented ( @cinnamon-bun seems like participatingAuthor isn't used in the most recently published release?)

Best of all, this opens the door to partial syncing.

Closes #6

@cinnamon-bun
Copy link
Member

⭐ 💫

seems like participatingAuthor isn't used in the most recently published release?

It's there for memory but not sqlite yet.

query memory sqlite
versionsByAuthor implemented implemented
participatingAuthor implemented not yet
lastAuthor not yet not yet

Issue: Implement participatingAuthor query in sqlite

@cinnamon-bun
Copy link
Member

P.S. you likely already saw this, but types.ts has the documentation about the different query options.

@sgwilym
Copy link
Collaborator Author

sgwilym commented Aug 4, 2020

@cinnamon-bun I was referring to it a lot! But now that I have you here... I read it again and again but I wasn't able to understand what the difference between versionsByAuthor and participatingAuthor is. Could you help me out? 😅

@cinnamon-bun
Copy link
Member

@sgwilym it's confusing. I don't know which kinds of queries we really need. Maybe I should remove some of these.

Example Data

most recent document versions are towards the right side
/path1: {author @a, content "1a"} {author @y, content "1y"}
/path2: {author @x, content "2x"} {author @a, content "2a"}
/path3: {author: @z, content "3z"}

Queries

The latest doc, by anyone, for any path that @a has touched
{participatingAuthor: @a, includeHistory: false} --> 1y, 2a

All doc versions, by anyone, for any path that @a has touched
{participatingAuthor: @a, includeHistory: true} --> 1a, 1y, 2x, 2a

Document versions by this author which are the latest in a path
{versionsByAuthor: @a, includeHistory: false} --> 2a

All document versions by this author including non-latest ones
{versionsByAuthor: @a, includeHistory: true} --> 1a, 2a

Paths where this author was the last writer; just the last doc
(Note this is the same as versionsByAuthor when history is false)
{lastAuthor: @a, includeHistory: false} --> 2a

Paths where this author was the last writer; and all history at that path
{lastAuthor: @a, includeHistory: true} --> 2x, 2a

@sgwilym
Copy link
Collaborator Author

sgwilym commented Aug 5, 2020

Ah, I had somehow missed this!

image

I kept thinking I was missing something because I kept reading versions and thinking "I thought only the latest version was kept...".

Thanks! I'm going to close this PR and merge in changes along with #11.

@sgwilym sgwilym closed this Aug 5, 2020
@sgwilym sgwilym deleted the document-filters branch August 5, 2020 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add filters for document fields
2 participants