Skip to content

Batches #11

@szavrakas

Description

@szavrakas

Hi guys,

We are looking at datastar and the concepts and the abstractions seems really nice. We have some questions about the batches. Here is the scenario:

We have a rest api and we have users and the threads resources. When we are posting a user we have to create a thread as well. The two tables that we currently have are:

users with fields (user_id, first_name, last_name, password)
threads with fields (thread_id, subject, user_id)

We are going to define the schema like that:

const cql = datastar.schema.cql;

const users = datastar.define('users', {
  ensureTables: true,
  schema: datastar.schema.object({
    user_id: cql.timeuuid({ default: 'v4' }),
    first_name: cql.text(),
    last_name: cql.text(),
    password: cql.text()
  }).partitionKey('user_id')
});

const threads = datastar.define('threads', {
  ensureTables: true,
  schema: datastar.schema.object({
    thread_id: cql.timeuuid({ default: 'v4' }),
    subject: cql.text().allow(null),
    user_id: cql.timeuuid()
  }).partitionKey('thread_id')
    .lookupKeys('user_id')
});

The fact that we've defined the threads schema above with the user_id as lookupKey it will create under the hood the table threads_by_user_id and when we are acting against the threads model/schema datastar will update the values in both tables using batches. Is this the case?

The question is how can we insert/update in batch between different model/schemas? For example, we would like to insert in the users table and the threads table (and sub-tables) and we would like to do it in a batch. Finally to insert to the following tables

users
threads
threads_by_user_id

As we see here on the blogpost one of the next features will be the batch update on multiple models. Is it the same thing that we are asking for and can we help somehow on that one?

Another thing that we'd like to ask is about the types. There are quite a lot of types defined, but we are using smallint as well. Is it enough to do the change on the joi-of-cql project or do we need to adapt this project accordingly?

Many thanks and sorry for the long post!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions