diff --git a/RSND/Core/Database.cs b/RSND/Core/Database.cs index 9d2e6d4..e4ac6c5 100644 --- a/RSND/Core/Database.cs +++ b/RSND/Core/Database.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Collections; +using Newtonsoft.Json; using Pastel; using RSND.Core.DbInternals; using RSND.Core.Querying.Queries; @@ -81,13 +82,11 @@ public class Database var table = query?.TableName; var key = query?.Key; var value = query?.Value; - var newValue = query?.NewValue; var tableToReturn = _tables.Find(x => x.Name == table); - var row = tableToReturn?.Rows?.FirstOrDefault(x => x.Columns?.FirstOrDefault(y => y.Name == key)?.Value == value); + var row = tableToReturn?.Rows?.FirstOrDefault(x => x.Columns?.FirstOrDefault(y => y.Name == key)?.Name == key); var column = row?.Columns?.FirstOrDefault(x => x.Name == key); - column.Value = newValue; - + column.Value = value; Save(); } @@ -95,16 +94,12 @@ public class Database { var table = query?.TableName; var columns = query?.Columns; - var tableToReturn = _tables.Find(x => x.Name == table); - - if (tableToReturn == null) return; - var row = new Row + tableToReturn?.Rows?.Add(new Row { Columns = columns - }; - tableToReturn.Rows?.Append(row); + }); Save(); } public static void Loop() diff --git a/RSND/Core/DbClient.cs b/RSND/Core/DbClient.cs index 208eeb7..6871abb 100644 --- a/RSND/Core/DbClient.cs +++ b/RSND/Core/DbClient.cs @@ -1,6 +1,5 @@ using Fleck; using Newtonsoft.Json; -using Pastel; using RSND.Core.DbInternals; using RSND.Core.Querying; using RSND.Core.Querying.Queries; diff --git a/RSND/Core/DbInternals/Row.cs b/RSND/Core/DbInternals/Row.cs index ea6961a..ccadb75 100644 --- a/RSND/Core/DbInternals/Row.cs +++ b/RSND/Core/DbInternals/Row.cs @@ -2,5 +2,5 @@ public class Row { - public Column[]? Columns; + public List? Columns; } \ No newline at end of file diff --git a/RSND/Core/DbInternals/Table.cs b/RSND/Core/DbInternals/Table.cs index a39debe..520c54f 100644 --- a/RSND/Core/DbInternals/Table.cs +++ b/RSND/Core/DbInternals/Table.cs @@ -3,5 +3,5 @@ public class Table { public string? Name; - public Row[]? Rows; + public List? Rows; } \ No newline at end of file diff --git a/RSND/Core/Querying/BaseQuery.cs b/RSND/Core/Querying/BaseQuery.cs index 7a6b2ba..562b39f 100644 --- a/RSND/Core/Querying/BaseQuery.cs +++ b/RSND/Core/Querying/BaseQuery.cs @@ -9,6 +9,6 @@ public class BaseQuery { Type = type; } - + public string Type { get; set; } } \ No newline at end of file diff --git a/RSND/Core/Querying/Queries/AddQuery.cs b/RSND/Core/Querying/Queries/AddQuery.cs index 1e68466..94563e1 100644 --- a/RSND/Core/Querying/Queries/AddQuery.cs +++ b/RSND/Core/Querying/Queries/AddQuery.cs @@ -5,5 +5,5 @@ namespace RSND.Core.Querying.Queries; public class AddQuery : Query { public string TableName { get; set; } - public Column[] Columns { get; set; } + public List Columns { get; set; } } \ No newline at end of file diff --git a/RSND/Core/Querying/Queries/CreateTableQuery.cs b/RSND/Core/Querying/Queries/CreateTableQuery.cs index b80da7a..32caeb8 100644 --- a/RSND/Core/Querying/Queries/CreateTableQuery.cs +++ b/RSND/Core/Querying/Queries/CreateTableQuery.cs @@ -4,12 +4,12 @@ namespace RSND.Core.Querying.Queries; public class CreateTableQuery : Query { - public CreateTableQuery(string tableName, Row[] rows) + public CreateTableQuery(string tableName, List rows) { TableName = tableName; Rows = rows; } public string TableName { get; set; } - public Row[] Rows; + public List? Rows; } \ No newline at end of file diff --git a/RSND/Core/Querying/Queries/SetQuery.cs b/RSND/Core/Querying/Queries/SetQuery.cs index dad3b92..50f053b 100644 --- a/RSND/Core/Querying/Queries/SetQuery.cs +++ b/RSND/Core/Querying/Queries/SetQuery.cs @@ -5,5 +5,4 @@ public class SetQuery : Query public string TableName { get; set; } public string Key { get; set; } public string Value { get; set; } - public string NewValue { get; set; } } \ No newline at end of file diff --git a/RSND/RsndMain.cs b/RSND/RsndMain.cs index 27847c8..a53534b 100644 --- a/RSND/RsndMain.cs +++ b/RSND/RsndMain.cs @@ -16,13 +16,13 @@ public static class RsndMain Db.CreateTable(new Table { Name = "fooTable", - Rows = new [] + Rows = new List { - new Row + new() { - Columns = new [] + Columns = new List { - new Column("test", "1") + new("test", "1") } } }