Giter Site home page Giter Site logo

Comments (5)

sgwilym avatar sgwilym commented on June 15, 2024

@cinnamon-bun Yes, this makes sense to me too!

I could implement this the way you suggest, but I have two thoughts:

  1. This approach hinges on the client having all documents available to sort.
  2. Sorting documents by the original publication date seems like a pattern that clients will want regularly, and requiring them to implement it themselves every time seems like it could be prone to error.

To expand on point one: at some point earthstar-graphql is going to return paginated connections for documents rather than any array with every document ever in it. There will still be ways to get every result in a single request, and I think this can be a valid approach with a client-side schema, but there are definitely UIs and situations you'll want only a portion of a workspace's documents at a time. At that point, you can't do things like client-side sorting of documents by publication date, because you won't have all docs available.

Secondly, if clients do this themselves they'll always have to store the timestamp somewhere, either in the document path or content, and for such a common use-case that seems a bit much to me.

I guess what I'm driving at is: could/should earthstar documents have an original publication date field?

from earthstar-lobby.

cinnamon-bun avatar cinnamon-bun commented on June 15, 2024

You're right! There will be a lot of cases like this where clients want to query by something that's not part of the core Document schema yet. Tags, categories, threads, creation timestamp, ...

I want to keep the core schema as small as possible, just what's needed for replication, so the specification can be stable.

I was considering adding a metadata object that you could easily query:

{
    path: "/posts/[email protected]/a93nhf-23jf9f-faj093j",
    content: "OMG so true",
    timestamp: 15000000077777,  // when updated
    metadata: {
        // put your own data here and it will be queryable
        creationTimestamp: 15000000000001,
        category: "intros",
        parentPost: "/posts/[email protected]/d923j-ajw049f-j328fa",
    }
}

More details in earthstar-project/earthstar#9

from earthstar-lobby.

sgwilym avatar sgwilym commented on June 15, 2024

Oh, nice. How do you imagine querying for that, would that be an extra field on QueryOpts?

from earthstar-lobby.

cinnamon-bun avatar cinnamon-bun commented on June 15, 2024

Yes, some built-in way to query and sort by this metadata. (Although we're on the verge of creating a full-fledged query language and I'd love to avoid that complexity.)

from earthstar-lobby.

sgwilym avatar sgwilym commented on June 15, 2024

I will do this the naive way by sorting all documents for now 😄

from earthstar-lobby.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.