|
|
@ -1,4 +1,5 @@ |
|
|
|
using Newtonsoft.Json; |
|
|
|
using Pastel; |
|
|
|
using RSND.Core.DbInternals; |
|
|
|
using RSND.Core.Querying.Queries; |
|
|
|
|
|
|
@ -8,9 +9,16 @@ public class Database |
|
|
|
{ |
|
|
|
List<Table> tables = new(); |
|
|
|
|
|
|
|
public void CreateTable(Table table) |
|
|
|
public void CreateTable(Table query) |
|
|
|
{ |
|
|
|
tables.Add(table); |
|
|
|
var matches = tables.FirstOrDefault(x => x.Name == query.Name); |
|
|
|
|
|
|
|
if (matches != null) |
|
|
|
{ |
|
|
|
tables.Remove(matches); |
|
|
|
} |
|
|
|
|
|
|
|
tables.Add(query); |
|
|
|
} |
|
|
|
|
|
|
|
private static string GetRowsJson(Row[]? rows) |
|
|
@ -20,7 +28,7 @@ public class Database |
|
|
|
|
|
|
|
public string GetValue(GetQuery? query) |
|
|
|
{ |
|
|
|
Console.WriteLine(tables.Count); |
|
|
|
Console.WriteLine(tables.Count.ToString().Pastel("#ff0000")); |
|
|
|
var table = query?.Table; |
|
|
|
var where = query?.Where; |
|
|
|
|
|
|
@ -33,15 +41,16 @@ public class Database |
|
|
|
|
|
|
|
|
|
|
|
var tableToReturn = tables.Find(x => x.Name == table); |
|
|
|
var rows = tableToReturn?.Rows?.Where(x => x.Columns.FirstOrDefault(y => y.Data.Key == colName)?.Data.Value == param).ToArray(); |
|
|
|
var rows = tableToReturn?.Rows?.Where(x => x.Columns?.FirstOrDefault(y => y.Data.Key == colName)?.Data.Value == param).ToArray(); |
|
|
|
|
|
|
|
return GetRowsJson(rows); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void Loop() |
|
|
|
{ |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |