SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

[STABILITY] [PROPOSAL] Formulate the LINQ plan for Rust and C# APIs for accessing database data to be consistent

Open cloutiertyler opened this issue 1 year ago • 4 comments

All types of queries should look the same:

  • Client querying local db
  • Client querying remote db
  • Module querying spacetime db
  • Client subscribing to remote db

And this should have some kind of LINQ syntax which generates a query datastructure/representation of the query which gets passed to spacetimedb to be executed.

For example see the following pseudocode/temporary syntax for the idea

let players = Player::filter_by_x(5).filter_by_z(0).execute();

// Where Player::filter_by_x(5).filter_by_z(0) actually just builds a query like
// "SELECT * FROM Player WHERE x = 5 AND z = 0" and then `.execute` executes it against the db
// except that we don't actually want to use SQL necessarily (and probably represented as AlgebraicValue).

cloutiertyler avatar Jun 11 '24 14:06 cloutiertyler

I will also note, that we should probably move away from the Player:: syntax as this does not allow for the same type to be used by multiple tables.

cloutiertyler avatar Jun 11 '24 14:06 cloutiertyler

as this does not allow for the same type to be used by multiple tables.

Not sure what you mean.

RReverser avatar Jun 11 '24 17:06 RReverser

I mean we should be able to have a SignedInPlayer table and SignedOutPlayer table that both use the same Rust struct type:

struct Player {

}

cloutiertyler avatar Jun 11 '24 17:06 cloutiertyler

I am moving this to be a P2 for 1.0 because with @joshua-spacetime's proposal for the physical index access methods we no longer need a LINQ plan for 1.0 and further more Phoebe should describe the entire surface area of the API here:

https://github.com/clockworklabs/SpacetimeDBPrivate/pull/866

cloutiertyler avatar Jul 15 '24 19:07 cloutiertyler