Add `AddQuery`

This commit is contained in:
j4ck 2022-06-04 00:33:59 +03:00
parent 76898f89c3
commit c4b9627422
5 changed files with 38 additions and 0 deletions

View File

@ -55,6 +55,17 @@ public class DbClient
RsndMain.Db.SetValue(setQuery);
break;
}
case QueryType.AddToTable:
{
AddQuery addQuery = JsonConvert.DeserializeObject<AddQuery>(query);
foreach (var column in addQuery?.Columns)
{
Console.WriteLine(column.Value);
}
break;
}
case QueryType.CreateTable:
{
CreateTableQuery createTableQuery = JsonConvert.DeserializeObject<CreateTableQuery>(query);

View File

@ -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; }
}

View File

@ -14,6 +14,7 @@ public static class QueryHelper
{
"GetValue" => QueryType.GetValue,
"SetValue" => QueryType.SetValue,
"AddToTable" => QueryType.AddToTable,
"CreateTable" => QueryType.CreateTable,
_ => null
};

View File

@ -4,5 +4,6 @@ public enum QueryType
{
GetValue,
SetValue,
AddToTable,
CreateTable
}

View File

@ -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;