Comments (4)
You need to provide partition key of the MV itself. Same as on original table. E.g. if you have table:
#[charybdis_model(
table_name = posts,
partition_keys = [date],
clustering_keys = [category_id, title]
)]
pub struct Post {
pub date: Date,
pub category_id: Uuid,
pub title: Text,
pub user_id: Uuid,
}
And you want to create MV posts_by_user, you would do:
#[charybdis_view_model(
table_name=posts_by_user,
base_table=posts,
partition_keys=[user_id],
clustering_keys=[date, category_id, title]
)]
pub struct PostByUser {
pub date: Date,
pub category_id: Uuid,
pub title: Text,
pub user_id: Uuid,,
}
Now you would be able to query by find_by_user_id
, find_by_user_id_and_date
...
from charybdis.
Now you would be able to query by find_by_user_id, find_by_user_id_and_date ...
Do you mean that it adds these methods to the original Post
struct?
I'm trying to do date < ?
rather than date = ?
which the regular find...
doesn't work with (I think?).
Can I do this or am I using the find
wrong?
PurchasesByChef::find(
"chef = ? and date < ? and id < ?",
(account_id, date, id),
)
.execute(&db)
.await
from charybdis.
Sorry I see now, you need to do following:
PurchasesByChef::find(
find_purchases_by_chef_query!("chef = ? and date < ?"),
(account_id, date),
)
.execute(&db)
.await
find_purchases_by_chef_query!
will build complete query as static str at compile time.
from charybdis.
Awesome, thank you!
from charybdis.
Related Issues (20)
- Static Columns HOT 2
- TLS support HOT 3
- Missing find by secondary index HOT 6
- How to use `Time` and `Duration`? HOT 7
- Can't find rows from just partition key HOT 3
- Composed Partition Keys in Materialized Views HOT 5
- Update field using GSI HOT 2
- Failed to type check Rust type uuid::Uuid against CQL type Timeuuid: expected one of the CQL types: [Uuid] HOT 2
- Enable delete by LSI HOT 2
- Empty set fails to deserialise back into empty hashset HOT 4
- Move charybdis::types into a separate feature/package HOT 3
- Update with a variable set of fields using MaybeUnset HOT 5
- Community resources HOT 2
- Custom types for migrations HOT 1
- Time to Live support HOT 5
- Proposal: a macro for expressions like WRITETIME(field)/TTL(field) HOT 3
- Macros aren't exported HOT 1
- Putting semi-colon in doc comments in models causes the macro to panic
- Feature: unconditional find
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from charybdis.