📣July 19th release is out!Read the release notes
    A dog learning a new trick on the moon

    Triplit REPL Learns Some New Tricks

    New experimental REPL features

    We've made some improvements to the REPL in the Triplit CLI. The REPL is a great way to interact with your Triplit database without having to write a full script. You can run it with triplit repl in your terminal. Inside the REPL, you can run queries and fetch data using the global triplit object, which is just a client syncing with your remote database.

    We've added a few new features to the REPL:

    • .schema will pretty-print the schema of the database.
    REPL Schema Pretty Printed
    • .fetch <collection> where <attribute> <op> <value> is SQL-inspired shorthand for triplit.fetch(triplit.query(<collection>).where(<attribute>, <op>, <value>)). At the moment it only supports specifying a collection and a filter, but we're planning to add support for other query parameters soon.
    REPL Fetch Pretty Printed

    Supporting undefined in filters

    You can now pass undefined to where filters in the query builder. We added this after finding ourselves needing to conditionally add filters to a query. By combining the additive behavior of our query behavior with the new undefined support, you can now conditionally add filters to a query. Here's an example from one of our internal todos apps:

    Before, when a filter like where([validFilter, undefined, undefined]) would throw errors, we had to write something ugly like this:

        ...(showCompleted ? [] : [['completed', '=', false]]),
        ...(selectedTag ? [['tagIds', '=', selectedTag]] : []),
        ...(textFilter ? [['text', 'like', textFilter]] : []),

    Now that undefined filters are ignored, we can write something more concise:

      .where(showCompleted ? undefined : ['completed', '=', false]),
      .where(selectedTag ? ['tagIds', '=', selectedTag] : undefined),
      .where(textFilter ? ['text', 'like', textFilter] : undefined);

    New RSS feed

    We've added an RSS feed to the Triplit blog. You can subscribe to it here.