// @generated by `zero-rust codegen` from packages/zql/src/query/test/test-schemas.ts. Do not edit. // // Declare it as `#[rustfmt::skip] mod schema;`: rustfmt would reformat it, // and `zero-rust codegen --check` compares it as generated. #![allow(dead_code)] use ::zero_client::typed as z; /// A row of `issue` (`issues` on the server). #[derive(Clone, Debug, PartialEq)] pub struct Issue { pub id: String, pub title: String, pub description: String, pub closed: bool, pub owner_id: Option, pub created_at: f64, // Relationships, filled when a query asks for them with `related`. pub owner: Option>, pub comments: Option>, pub one_comment: Option>, pub owner_comments: Option>, pub labels: Option>, /// The aggregates a query asked for in `related`. pub aggregates: z::RelationshipAggregates, } impl Issue { pub const ID: z::Column = z::Column::new("id"); pub const TITLE: z::Column = z::Column::new("title"); pub const DESCRIPTION: z::Column = z::Column::new("description"); pub const CLOSED: z::Column = z::Column::new("closed"); pub const OWNER_ID: z::Column> = z::Column::new("ownerId"); pub const CREATED_AT: z::Column = z::Column::new("createdAt"); pub const OWNER: z::Relationship = z::Relationship::new("owner"); pub const COMMENTS: z::Relationship = z::Relationship::new("comments"); pub const ONE_COMMENT: z::Relationship = z::Relationship::new("oneComment"); pub const OWNER_COMMENTS: z::Relationship = z::Relationship::new("ownerComments"); pub const LABELS: z::Relationship = z::Relationship::new("labels"); } impl z::QueryElement for Issue { fn from_entry(entry: &z::ViewEntry) -> Result { Ok(Issue { id: z::column(entry, "id", 0)?, title: z::column(entry, "title", 1)?, description: z::column(entry, "description", 2)?, closed: z::column(entry, "closed", 3)?, owner_id: z::column(entry, "ownerId", 4)?, created_at: z::column(entry, "createdAt", 5)?, owner: z::one(entry, "owner")?, comments: z::many(entry, "comments")?, one_comment: z::one(entry, "oneComment")?, owner_comments: z::many(entry, "ownerComments")?, labels: z::many(entry, "labels")?, aggregates: z::RelationshipAggregates::from_entry(entry), }) } } impl z::ZeroRow for Issue { const TABLE: &'static str = "issue"; type Update = IssueUpdate; type Key = IssueKey; fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(6); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row.insert("title", z::ZeroValue::to_zero_value(&self.title)); row.insert("description", z::ZeroValue::to_zero_value(&self.description)); row.insert("closed", z::ZeroValue::to_zero_value(&self.closed)); row.insert("ownerId", z::ZeroValue::to_zero_value(&self.owner_id)); row.insert("createdAt", z::ZeroValue::to_zero_value(&self.created_at)); row } } impl z::OptionalQueryElement for Issue { fn optional_from_view(view: &z::ViewValue) -> Result, z::ZeroValueError> { z::optional_row(view) } } /// What `mutate::issue(tx).update` takes: the primary key, and the other columns to set. A column that is `None`, or `ColumnUpdate::Unchanged`, keeps its value. #[derive(Clone, Debug, PartialEq)] pub struct IssueUpdate { pub id: String, pub title: Option, pub description: Option, pub closed: Option, pub owner_id: z::ColumnUpdate, pub created_at: Option, } impl IssueUpdate { /// The primary key, with every other column left as it is. pub fn new(id: String) -> Self { IssueUpdate { id, title: None, description: None, closed: None, owner_id: z::ColumnUpdate::Unchanged, created_at: None, } } } impl z::ColumnValues for IssueUpdate { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(6); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); if let Some(v) = &self.title { row.insert("title", z::ZeroValue::to_zero_value(v)); } if let Some(v) = &self.description { row.insert("description", z::ZeroValue::to_zero_value(v)); } if let Some(v) = &self.closed { row.insert("closed", z::ZeroValue::to_zero_value(v)); } if let Some(v) = self.owner_id.to_zero_value() { row.insert("ownerId", v); } if let Some(v) = &self.created_at { row.insert("createdAt", z::ZeroValue::to_zero_value(v)); } row } } /// What `mutate::issue(tx).delete` takes: the primary key. #[derive(Clone, Debug, PartialEq)] pub struct IssueKey { pub id: String, } impl z::ColumnValues for IssueKey { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } /// A row of `user` (`users` on the server). #[derive(Clone, Debug, PartialEq)] pub struct User { pub id: String, pub name: String, pub metadata: Option, // Relationships, filled when a query asks for them with `related`. pub issues: Option>, /// The aggregates a query asked for in `related`. pub aggregates: z::RelationshipAggregates, } impl User { pub const ID: z::Column = z::Column::new("id"); pub const NAME: z::Column = z::Column::new("name"); pub const METADATA: z::Column> = z::Column::new("metadata"); pub const ISSUES: z::Relationship = z::Relationship::new("issues"); } impl z::QueryElement for User { fn from_entry(entry: &z::ViewEntry) -> Result { Ok(User { id: z::column(entry, "id", 0)?, name: z::column(entry, "name", 1)?, metadata: z::column(entry, "metadata", 2)?, issues: z::many(entry, "issues")?, aggregates: z::RelationshipAggregates::from_entry(entry), }) } } impl z::ZeroRow for User { const TABLE: &'static str = "user"; type Update = UserUpdate; type Key = UserKey; fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(3); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row.insert("name", z::ZeroValue::to_zero_value(&self.name)); row.insert("metadata", z::ZeroValue::to_zero_value(&self.metadata)); row } } impl z::OptionalQueryElement for User { fn optional_from_view(view: &z::ViewValue) -> Result, z::ZeroValueError> { z::optional_row(view) } } /// What `mutate::user(tx).update` takes: the primary key, and the other columns to set. A column that is `None`, or `ColumnUpdate::Unchanged`, keeps its value. #[derive(Clone, Debug, PartialEq)] pub struct UserUpdate { pub id: String, pub name: Option, pub metadata: z::ColumnUpdate, } impl UserUpdate { /// The primary key, with every other column left as it is. pub fn new(id: String) -> Self { UserUpdate { id, name: None, metadata: z::ColumnUpdate::Unchanged, } } } impl z::ColumnValues for UserUpdate { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(3); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); if let Some(v) = &self.name { row.insert("name", z::ZeroValue::to_zero_value(v)); } if let Some(v) = self.metadata.to_zero_value() { row.insert("metadata", v); } row } } /// What `mutate::user(tx).delete` takes: the primary key. #[derive(Clone, Debug, PartialEq)] pub struct UserKey { pub id: String, } impl z::ColumnValues for UserKey { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } /// A row of `comment` (`comments` on the server). #[derive(Clone, Debug, PartialEq)] pub struct Comment { pub id: String, pub author_id: String, pub issue_id: String, pub text: String, pub created_at: f64, // Relationships, filled when a query asks for them with `related`. pub issue: Option>, pub revisions: Option>, pub author: Option>, /// The aggregates a query asked for in `related`. pub aggregates: z::RelationshipAggregates, } impl Comment { pub const ID: z::Column = z::Column::new("id"); pub const AUTHOR_ID: z::Column = z::Column::new("authorId"); pub const ISSUE_ID: z::Column = z::Column::new("issueId"); pub const TEXT: z::Column = z::Column::new("text"); pub const CREATED_AT: z::Column = z::Column::new("createdAt"); pub const ISSUE: z::Relationship = z::Relationship::new("issue"); pub const REVISIONS: z::Relationship = z::Relationship::new("revisions"); pub const AUTHOR: z::Relationship = z::Relationship::new("author"); } impl z::QueryElement for Comment { fn from_entry(entry: &z::ViewEntry) -> Result { Ok(Comment { id: z::column(entry, "id", 0)?, author_id: z::column(entry, "authorId", 1)?, issue_id: z::column(entry, "issueId", 2)?, text: z::column(entry, "text", 3)?, created_at: z::column(entry, "createdAt", 4)?, issue: z::one(entry, "issue")?, revisions: z::many(entry, "revisions")?, author: z::one(entry, "author")?, aggregates: z::RelationshipAggregates::from_entry(entry), }) } } impl z::ZeroRow for Comment { const TABLE: &'static str = "comment"; type Update = CommentUpdate; type Key = CommentKey; fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(5); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row.insert("authorId", z::ZeroValue::to_zero_value(&self.author_id)); row.insert("issueId", z::ZeroValue::to_zero_value(&self.issue_id)); row.insert("text", z::ZeroValue::to_zero_value(&self.text)); row.insert("createdAt", z::ZeroValue::to_zero_value(&self.created_at)); row } } impl z::OptionalQueryElement for Comment { fn optional_from_view(view: &z::ViewValue) -> Result, z::ZeroValueError> { z::optional_row(view) } } /// What `mutate::comment(tx).update` takes: the primary key, and the other columns to set. A column that is `None`, or `ColumnUpdate::Unchanged`, keeps its value. #[derive(Clone, Debug, PartialEq)] pub struct CommentUpdate { pub id: String, pub author_id: Option, pub issue_id: Option, pub text: Option, pub created_at: Option, } impl CommentUpdate { /// The primary key, with every other column left as it is. pub fn new(id: String) -> Self { CommentUpdate { id, author_id: None, issue_id: None, text: None, created_at: None, } } } impl z::ColumnValues for CommentUpdate { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(5); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); if let Some(v) = &self.author_id { row.insert("authorId", z::ZeroValue::to_zero_value(v)); } if let Some(v) = &self.issue_id { row.insert("issueId", z::ZeroValue::to_zero_value(v)); } if let Some(v) = &self.text { row.insert("text", z::ZeroValue::to_zero_value(v)); } if let Some(v) = &self.created_at { row.insert("createdAt", z::ZeroValue::to_zero_value(v)); } row } } /// What `mutate::comment(tx).delete` takes: the primary key. #[derive(Clone, Debug, PartialEq)] pub struct CommentKey { pub id: String, } impl z::ColumnValues for CommentKey { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } /// A row of `revision`. #[derive(Clone, Debug, PartialEq)] pub struct Revision { pub id: String, pub author_id: String, pub comment_id: String, pub text: String, // Relationships, filled when a query asks for them with `related`. pub comment: Option>, pub author: Option>, /// The aggregates a query asked for in `related`. pub aggregates: z::RelationshipAggregates, } impl Revision { pub const ID: z::Column = z::Column::new("id"); pub const AUTHOR_ID: z::Column = z::Column::new("authorId"); pub const COMMENT_ID: z::Column = z::Column::new("commentId"); pub const TEXT: z::Column = z::Column::new("text"); pub const COMMENT: z::Relationship = z::Relationship::new("comment"); pub const AUTHOR: z::Relationship = z::Relationship::new("author"); } impl z::QueryElement for Revision { fn from_entry(entry: &z::ViewEntry) -> Result { Ok(Revision { id: z::column(entry, "id", 0)?, author_id: z::column(entry, "authorId", 1)?, comment_id: z::column(entry, "commentId", 2)?, text: z::column(entry, "text", 3)?, comment: z::one(entry, "comment")?, author: z::one(entry, "author")?, aggregates: z::RelationshipAggregates::from_entry(entry), }) } } impl z::ZeroRow for Revision { const TABLE: &'static str = "revision"; type Update = RevisionUpdate; type Key = RevisionKey; fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(4); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row.insert("authorId", z::ZeroValue::to_zero_value(&self.author_id)); row.insert("commentId", z::ZeroValue::to_zero_value(&self.comment_id)); row.insert("text", z::ZeroValue::to_zero_value(&self.text)); row } } impl z::OptionalQueryElement for Revision { fn optional_from_view(view: &z::ViewValue) -> Result, z::ZeroValueError> { z::optional_row(view) } } /// What `mutate::revision(tx).update` takes: the primary key, and the other columns to set. A column that is `None`, or `ColumnUpdate::Unchanged`, keeps its value. #[derive(Clone, Debug, PartialEq)] pub struct RevisionUpdate { pub id: String, pub author_id: Option, pub comment_id: Option, pub text: Option, } impl RevisionUpdate { /// The primary key, with every other column left as it is. pub fn new(id: String) -> Self { RevisionUpdate { id, author_id: None, comment_id: None, text: None, } } } impl z::ColumnValues for RevisionUpdate { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(4); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); if let Some(v) = &self.author_id { row.insert("authorId", z::ZeroValue::to_zero_value(v)); } if let Some(v) = &self.comment_id { row.insert("commentId", z::ZeroValue::to_zero_value(v)); } if let Some(v) = &self.text { row.insert("text", z::ZeroValue::to_zero_value(v)); } row } } /// What `mutate::revision(tx).delete` takes: the primary key. #[derive(Clone, Debug, PartialEq)] pub struct RevisionKey { pub id: String, } impl z::ColumnValues for RevisionKey { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } /// A row of `label`. #[derive(Clone, Debug, PartialEq)] pub struct Label { pub id: String, pub name: String, // Relationships, filled when a query asks for them with `related`. pub issues: Option>, /// The aggregates a query asked for in `related`. pub aggregates: z::RelationshipAggregates