nullnet_libdatastore/builders/
batch_create_request_builder.rs1use crate::datastore::{BatchCreateBody, BatchCreateRequest, CreateParams, Query};
2
3#[derive(Debug, Default)]
4pub struct BatchCreateRequestBuilder {
5 table: Option<String>,
6 pluck: Option<String>,
7 durability: Option<String>,
8 records: Option<String>,
9 entity_prefix: Option<String>,
10}
11
12impl BatchCreateRequestBuilder {
13 pub fn new() -> Self {
14 Self::default()
15 }
16
17 pub fn table(mut self, table: impl Into<String>) -> Self {
18 self.table = Some(table.into());
19 self
20 }
21
22 pub fn pluck(mut self, pluck: impl Into<String>) -> Self {
23 self.pluck = Some(pluck.into());
24 self
25 }
26
27 pub fn durability(mut self, durability: impl Into<String>) -> Self {
28 self.durability = Some(durability.into());
29 self
30 }
31
32 pub fn records(mut self, records: impl Into<String>) -> Self {
33 self.records = Some(records.into());
34 self
35 }
36
37 pub fn entity_prefix(mut self, prefix: impl Into<String>) -> Self {
38 self.entity_prefix = Some(prefix.into());
39 self
40 }
41
42 pub fn build(self) -> BatchCreateRequest {
43 BatchCreateRequest {
44 params: Some(CreateParams {
45 table: self.table.unwrap_or_default(),
46 }),
47 query: Some(Query {
48 pluck: self.pluck.unwrap_or_default(),
49 durability: self.durability.unwrap_or_else(|| "soft".into()),
50 }),
51 body: Some(BatchCreateBody {
52 records: self.records.unwrap_or_default(),
53 }),
54 }
55 }
56}