Reworks
This commit is contained in:
parent
2b87d05e9e
commit
76898f89c3
|
@ -62,14 +62,10 @@ public class Database
|
|||
|
||||
public string GetValue(GetQuery? query)
|
||||
{
|
||||
Console.WriteLine(_tables.Count.ToString().Pastel("#ff0000"));
|
||||
var table = query?.TableName;
|
||||
var where = query?.Where;
|
||||
|
||||
var split = where?.Split("|");
|
||||
var colName = split?[0];
|
||||
var condition = split?[1];
|
||||
var value = split?[2];
|
||||
var colName = query?.Key;
|
||||
var value = query?.Value;
|
||||
|
||||
if (query?.Select != "*") return "";
|
||||
|
||||
|
@ -87,15 +83,12 @@ public class Database
|
|||
var value = query?.Value;
|
||||
var newValue = query?.NewValue;
|
||||
|
||||
Console.WriteLine(table);
|
||||
var tableToReturn = _tables.Find(x => x.Name == table);
|
||||
Console.WriteLine(tableToReturn == null ? "shits null" : "shits not null");
|
||||
Console.WriteLine(key);
|
||||
var row = tableToReturn?.Rows?.FirstOrDefault(x => x.Columns?.FirstOrDefault(y => y.Name == key)?.Value == value);
|
||||
var column = row?.Columns?.FirstOrDefault(x => x.Name == key);
|
||||
column.Value = newValue;
|
||||
|
||||
Console.WriteLine(column.Value);
|
||||
Save();
|
||||
}
|
||||
|
||||
public static void Loop()
|
||||
|
|
|
@ -47,7 +47,6 @@ public class DbClient
|
|||
GetQuery getQuery = JsonConvert.DeserializeObject<GetQuery>(query);
|
||||
var queryResult = RsndMain.Db.GetValue(getQuery);
|
||||
_socket.Send(queryResult);
|
||||
Console.WriteLine($"Sent: {queryResult}".Pastel("#71C562"));
|
||||
break;
|
||||
}
|
||||
case QueryType.SetValue:
|
||||
|
|
|
@ -2,14 +2,16 @@
|
|||
|
||||
public class GetQuery : Query
|
||||
{
|
||||
public GetQuery(string tableName, string select, string where)
|
||||
public GetQuery(string tableName, string select, string key, string value)
|
||||
{
|
||||
TableName = tableName;
|
||||
Select = select;
|
||||
Where = where;
|
||||
Key = key;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public string TableName { get; set; }
|
||||
public string Select { get; set; }
|
||||
public string Where { get; set; }
|
||||
public string Key { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
|
@ -13,7 +13,7 @@ public static class RsndMain
|
|||
Db.Save();
|
||||
|
||||
WebSocketServer server = new WebSocketServer("ws://0.0.0.0:7878");
|
||||
|
||||
Console.WriteLine("Server started");
|
||||
FleckLog.Level = LogLevel.Error;
|
||||
|
||||
server.Start(socket =>
|
||||
|
|
Loading…
Reference in New Issue