From c4b96274222ab10555983b412ecb0b32752f6bc0 Mon Sep 17 00:00:00 2001 From: j4ck <50369519+j4cegh@users.noreply.github.com> Date: Sat, 4 Jun 2022 00:33:59 +0300 Subject: [PATCH] Add `AddQuery` --- RSND/Core/DbClient.cs | 11 +++++++++++ RSND/Core/Querying/Queries/AddQuery.cs | 9 +++++++++ RSND/Core/Querying/QueryHelper.cs | 1 + RSND/Core/Querying/QueryType.cs | 1 + RSND/RsndMain.cs | 16 ++++++++++++++++ 5 files changed, 38 insertions(+) create mode 100644 RSND/Core/Querying/Queries/AddQuery.cs diff --git a/RSND/Core/DbClient.cs b/RSND/Core/DbClient.cs index 1b3e888..8ced192 100644 --- a/RSND/Core/DbClient.cs +++ b/RSND/Core/DbClient.cs @@ -55,6 +55,17 @@ public class DbClient RsndMain.Db.SetValue(setQuery); break; } + case QueryType.AddToTable: + { + AddQuery addQuery = JsonConvert.DeserializeObject(query); + foreach (var column in addQuery?.Columns) + { + Console.WriteLine(column.Value); + } + + + break; + } case QueryType.CreateTable: { CreateTableQuery createTableQuery = JsonConvert.DeserializeObject(query); diff --git a/RSND/Core/Querying/Queries/AddQuery.cs b/RSND/Core/Querying/Queries/AddQuery.cs new file mode 100644 index 0000000..1e68466 --- /dev/null +++ b/RSND/Core/Querying/Queries/AddQuery.cs @@ -0,0 +1,9 @@ +using RSND.Core.DbInternals; + +namespace RSND.Core.Querying.Queries; + +public class AddQuery : Query +{ + public string TableName { get; set; } + public Column[] Columns { get; set; } +} \ No newline at end of file diff --git a/RSND/Core/Querying/QueryHelper.cs b/RSND/Core/Querying/QueryHelper.cs index cb33f6b..7299ad3 100644 --- a/RSND/Core/Querying/QueryHelper.cs +++ b/RSND/Core/Querying/QueryHelper.cs @@ -14,6 +14,7 @@ public static class QueryHelper { "GetValue" => QueryType.GetValue, "SetValue" => QueryType.SetValue, + "AddToTable" => QueryType.AddToTable, "CreateTable" => QueryType.CreateTable, _ => null }; diff --git a/RSND/Core/Querying/QueryType.cs b/RSND/Core/Querying/QueryType.cs index b354a44..6d60d2e 100644 --- a/RSND/Core/Querying/QueryType.cs +++ b/RSND/Core/Querying/QueryType.cs @@ -4,5 +4,6 @@ public enum QueryType { GetValue, SetValue, + AddToTable, CreateTable } \ No newline at end of file diff --git a/RSND/RsndMain.cs b/RSND/RsndMain.cs index 8eb1c01..27847c8 100644 --- a/RSND/RsndMain.cs +++ b/RSND/RsndMain.cs @@ -1,5 +1,6 @@ using Fleck; using RSND.Core; +using RSND.Core.DbInternals; namespace RSND; @@ -12,6 +13,21 @@ public static class RsndMain Db.SetupFiles(); Db.Save(); + Db.CreateTable(new Table + { + Name = "fooTable", + Rows = new [] + { + new Row + { + Columns = new [] + { + new Column("test", "1") + } + } + } + }); + WebSocketServer server = new WebSocketServer("ws://0.0.0.0:7878"); Console.WriteLine("Server started"); FleckLog.Level = LogLevel.Error;