-
Notifications
You must be signed in to change notification settings - Fork 0
Rust Diesel 数据结构
duangsuse edited this page May 31, 2018
·
1 revision
#[derive(Queryable)]
pub struct User {
id: i16,
simple_name: String,
avatar_url: Option<String>,
user_name: String,
alias: Option<String>,
github: Option<String>,
bio: String,
dev_bio: Option<String>,
created_at: SystemTime,
online_at SystemTime,
followers_num: i16,
enabled: bool
}
#[derive(Insertable)]
#[table_name="users"]
pub struct NewUser<'a> {
simple_name: String,
avatar_url: Option<String>,
user_name: String,
alias: Option<String>,
github: Option<String>,
bio: String,
dev_bio: Option<String>
}
#[derive(Queryable)]
pub struct Category {
id: i16,
category_name: String,
parent_category: Option<i16>
}
#[derive(Insertable)]
#[table_name="categories"]
pub struct NewCategory<'a> {
category_name: String,
parent_category: Option<i16>
}
#[derive(Queryable)]
pub struct App {
id: i16,
author_user: i16,
category: i16,
package_name: Option<String>,
app_name: String,
alias: Option<String>,
icon_url: Option<String>,
app_description: String,
visualizer: Option<String>,
button_text: Option<String>,
special: Option<String>,
previews: Option<String>,
app_permissions: Option<String>,
size: i32,
created_at: SystemTime,
updated_at: SystemTime,
stars_num: i16,
comments_num: i32
}
#[derive(Insertable)]
#[table_name="apps"]
pub struct NewApp<'a> {
author_user: i16,
category: i16,
package_name: Option<String>,
app_name: String,
alias: Option<String>,
icon_url: Option<String>,
app_description: String,
visualizer: Option<String>,
button_text: Option<String>,
special: Option<String>,
previews: Option<String>,
app_permissions: Option<String>,
size: i32
}
#[derive(Queryable)]
pub struct Comment {
id: i32,
author_user: i16,
app: i16,
reply_comment: Option<i32>,
content: String,
stars_num: i16,
replies_num: i32,
created_at: SystemTime,
updated_at: Option<SystemTime>
}
#[derive(Insertable)]
#[table_name="comments"]
pub struct NewComment<'a> {
author_user: i16,
app: i16,
reply_comment: Option<i32>,
content: String
}
#[derive(Queryable)]
#[table_name="follow"]
pub struct Follow {
user: i16,
followed_user: i16
}
#[derive(Insertable)]
#[table_name="follow"]
pub struct NewFollow<'a> {
user: i16,
followed_user: i16
}
#[derive(Queryable)]
#[table_name="_security"]
pub struct Security {
user: i16,
metapass: String,
passhash: Option<String>
}
#[derive(Insertable)]
#[table_name="_security"]
pub struct NewSecurity<'a> {
user: i16,
metapass: String,
passhash: Option<String>
}
#[derive(Queryable)]
pub struct Update {
app: i16,
version: String,
reversion: i16,
install_url: String,
updates: String,
api_min: Option<i16>,
api_target: Option<i16>
}
#[derive(Insertable)]
#[table_name="updates"]
pub struct NewUpdate<'a> {
app: i16,
version: String,
reversion: i16,
install_url: String,
updates: String,
api_min: Option<i16>,
api_target: Option<i16>
}
#[derive(Queryable)]
pub struct Star {
user: i16,
app: i16
}
#[derive(Insertable)]
#[table_name="stars"]
pub struct NewStar<'a> {
user: i16,
app: i16
}
#[derive(Queryable)]
pub struct CommentStar {
user: i16,
comment: i32
}
#[derive(Insertable)]
#[table_name="comment_stars"]
pub struct NewCommentStar<'a> {
user: i16,
comment: i32
}
#[derive(Queryable)]
pub struct Timeline {
user: i16,
created_at: SystemTime,
line_type: i16,
line_data: i32
}
#[derive(Insertable)]
#[table_name="timelines"]
pub struct NewTimeline<'a> {
user: i16,
line_type: i16,
line_data: i32
}
#[derive(Queryable)]
pub struct Notification {
user: i16,
created_at: SystemTime,
notification_type: i16,
notification_data: i32,
enabled: bool
}
#[derive(Insertable)]
#[table_name="notifications"]
pub struct NewNotification<'a> {
user: i16,
notification_type: i16,
notification_data: i32,
}