clockworklabs / clockworklabs/SpacetimeDB
Table Insert Problems
@jdetter is already working on this.
Since Oct 14, 2025.
- Dominant language
- Rust
- Stars
- 25.2k
- Forks
- 1.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 46
Description
I wish to do a cached message for client, to avoid all message sent to a new client. but we dont have a way to do that, then I manage to maintain
two tables to do that. on for keep all ,one for keep the newst 10 messages.
but both dont works.
SQL can not support the ORDER
and
when Insert to a table, it can not insert in order also。
so how can I do, or can you make some method to do that,
not everything need to sync。。
PS /home/ubuntu> spacetime sql combat "SELECT * FROM world_message"
WARNING: This command is UNSTABLE and subject to breaking changes.
sender | name | sent | text
-------------------------------------------------------------------------------+----------------+------------------+------
87749735942141927258676195533202707267511107059813012757897815701149281837291 | "我是头号玩家" | 1741868642733860 | "16"
87749735942141927258676195533202707267511107059813012757897815701149281837291 | "我是头号玩家" | 1741868642733624 | "15"
87749735942141927258676195533202707267511107059813012757897815701149281837291 | "我是头号玩家" | 1741868642733379 | "14"
87749735942141927258676195533202707267511107059813012757897815701149281837291 | "我是头号玩家" | 1741868642733152 | "13"
87749735942141927258676195533202707267511107059813012757897815701149281837291 | "我是头号玩家" | 1741868642732828 | "12"
87749735942141927258676195533202707267511107059813012757897815701149281837291 | "我是头号玩家" | 1741868642732522 | "11"
the code is show bellow
ctx.db.world_message_all().insert(new_message.clone());
ctx.db.world_message().insert(new_message)
// more than 10 ,clear all of the table
if ctx.db.world_message().count() >= 10 {
// delete
for msg in ctx.db.world_message().iter() {
ctx.db.world_message().delete(msg);
}
}
Ok(())
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.