clockworklabs / SpacetimeDB

Multiplayer at the speed of light
https://spacetimedb.com
Other
4.29k stars 106 forks source link

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

Open cloutiertyler opened 2 months ago

cloutiertyler commented 2 months ago

All types of queries should look the same:

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 commented 2 months ago

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.

RReverser commented 2 months ago

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

Not sure what you mean.

cloutiertyler commented 2 months ago

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 commented 1 month ago

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