Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/databases/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,27 @@

use super::tables::table::Table;

struct Database {
pub struct Database {
name: String,
tables: Vec<Table>,
}

impl Database {
pub fn new(tables: Vec<Table>) -> Self {
pub fn create_database(name: String, tables: Vec<Table>) -> Self {
Self {
tables
name,
tables,
}
}

pub fn create_database_without_tables(name: String) -> Self {
Self {
name,
tables: Vec::new(),
}
}

pub fn delete_table(&mut self, name: String) {
todo!()
}
}
19 changes: 18 additions & 1 deletion src/databases/tables/rows/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,30 @@
*/

pub struct Row {
primary_key: u32,
columns: Vec<String>,
}

impl Row {
pub fn new(id: u32, columns: Vec<String>) -> Self {
pub fn create_row(primary_key: u32, columns: Vec<String>) -> Self {
Self {
primary_key,
columns,
}
}

pub fn create_row_without_columns(primary_key: u32) -> Self {
Self {
primary_key,
columns: Vec::new(),
}
}

pub fn create_column(&mut self, primary_key: u32, name: String) {
todo!()
}

pub fn delete_column(&mut self, name: String) {
todo!()
}
}
13 changes: 12 additions & 1 deletion src/databases/tables/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,21 @@ pub struct Table {
}

impl Table {
pub fn new(name: String, rows: HashMap<u32, Row>) -> Self {
pub fn create_table(name: String, rows: HashMap<u32, Row>) -> Self {
Self {
name,
rows,
}
}

pub fn create_table_without_rows(name: String) -> Self {
Self {
name,
rows: HashMap::new(),
}
}

pub fn delete_row(&mut self, primary_key: u32) {
todo!()
}
}
13 changes: 12 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pub(crate) mod databases;
pub(crate) mod databases;
use crate::databases::database::Database;

struct RNSQL {
databases: Vec<Database>,
}

impl RNSQL {
pub fn new() {
todo!()
}
}