Skip to content

Commit f8d65e5

Browse files
authored
Merge pull request #12 v0.1.0-remake
v0.1.0-remake
2 parents 56f54aa + 41386b3 commit f8d65e5

File tree

4 files changed

+58
-6
lines changed

4 files changed

+58
-6
lines changed

src/databases/database.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,27 @@
1818

1919
use super::tables::table::Table;
2020

21-
struct Database {
21+
pub struct Database {
22+
name: String,
2223
tables: Vec<Table>,
2324
}
2425

2526
impl Database {
26-
pub fn new(tables: Vec<Table>) -> Self {
27+
pub fn create_database(name: String, tables: Vec<Table>) -> Self {
2728
Self {
28-
tables
29+
name,
30+
tables,
2931
}
3032
}
33+
34+
pub fn create_database_without_tables(name: String) -> Self {
35+
Self {
36+
name,
37+
tables: Vec::new(),
38+
}
39+
}
40+
41+
pub fn delete_table(&mut self, name: String) {
42+
todo!()
43+
}
3144
}

src/databases/tables/rows/row.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,30 @@
1717
*/
1818

1919
pub struct Row {
20+
primary_key: u32,
2021
columns: Vec<String>,
2122
}
2223

2324
impl Row {
24-
pub fn new(id: u32, columns: Vec<String>) -> Self {
25+
pub fn create_row(primary_key: u32, columns: Vec<String>) -> Self {
2526
Self {
27+
primary_key,
2628
columns,
2729
}
2830
}
31+
32+
pub fn create_row_without_columns(primary_key: u32) -> Self {
33+
Self {
34+
primary_key,
35+
columns: Vec::new(),
36+
}
37+
}
38+
39+
pub fn create_column(&mut self, primary_key: u32, name: String) {
40+
todo!()
41+
}
42+
43+
pub fn delete_column(&mut self, name: String) {
44+
todo!()
45+
}
2946
}

src/databases/tables/table.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,21 @@ pub struct Table {
2525
}
2626

2727
impl Table {
28-
pub fn new(name: String, rows: HashMap<u32, Row>) -> Self {
28+
pub fn create_table(name: String, rows: HashMap<u32, Row>) -> Self {
2929
Self {
3030
name,
3131
rows,
3232
}
3333
}
34+
35+
pub fn create_table_without_rows(name: String) -> Self {
36+
Self {
37+
name,
38+
rows: HashMap::new(),
39+
}
40+
}
41+
42+
pub fn delete_row(&mut self, primary_key: u32) {
43+
todo!()
44+
}
3445
}

src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,15 @@
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
pub(crate) mod databases;
19+
pub(crate) mod databases;
20+
use crate::databases::database::Database;
21+
22+
struct RNSQL {
23+
databases: Vec<Database>,
24+
}
25+
26+
impl RNSQL {
27+
pub fn new() {
28+
todo!()
29+
}
30+
}

0 commit comments

Comments
 (0)