You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
using Newtonsoft.Json;
|
|
using RSND.Core.DbInternals;
|
|
using RSND.Core.Querying.Queries;
|
|
|
|
namespace RSND.Core;
|
|
|
|
public class Database
|
|
{
|
|
List<Table> tables = new();
|
|
|
|
public void CreateTable(Table table)
|
|
{
|
|
tables.Add(table);
|
|
}
|
|
|
|
private static string GetRowsJson(Row[]? rows)
|
|
{
|
|
return JsonConvert.SerializeObject(new { Rows = rows });
|
|
}
|
|
|
|
public string GetValue(GetQuery? query)
|
|
{
|
|
Console.WriteLine(tables.Count);
|
|
var table = query?.Table;
|
|
var where = query?.Where;
|
|
|
|
var split = where?.Split("|");
|
|
var colName = split?[0];
|
|
var condition = split?[1];
|
|
var param = split?[2];
|
|
|
|
if (query?.Select != "*") return "";
|
|
|
|
|
|
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();
|
|
|
|
return GetRowsJson(rows);
|
|
}
|
|
|
|
public static void Loop()
|
|
{
|
|
while (true)
|
|
{
|
|
}
|
|
}
|
|
}
|