A lot of changes. If you care, check it out.

This commit is contained in:
j4ck 2022-06-04 19:06:25 +03:00
parent 9e2be5bb51
commit 72cf566049
9 changed files with 16 additions and 23 deletions

View File

@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System.Collections;
using Newtonsoft.Json;
using Pastel;
using RSND.Core.DbInternals;
using RSND.Core.Querying.Queries;
@ -81,13 +82,11 @@ public class Database
var table = query?.TableName;
var key = query?.Key;
var value = query?.Value;
var newValue = query?.NewValue;
var tableToReturn = _tables.Find(x => x.Name == table);
var row = tableToReturn?.Rows?.FirstOrDefault(x => x.Columns?.FirstOrDefault(y => y.Name == key)?.Value == value);
var row = tableToReturn?.Rows?.FirstOrDefault(x => x.Columns?.FirstOrDefault(y => y.Name == key)?.Name == key);
var column = row?.Columns?.FirstOrDefault(x => x.Name == key);
column.Value = newValue;
column.Value = value;
Save();
}
@ -95,16 +94,12 @@ public class Database
{
var table = query?.TableName;
var columns = query?.Columns;
var tableToReturn = _tables.Find(x => x.Name == table);
if (tableToReturn == null) return;
var row = new Row
tableToReturn?.Rows?.Add(new Row
{
Columns = columns
};
tableToReturn.Rows?.Append(row);
});
Save();
}
public static void Loop()

View File

@ -1,6 +1,5 @@
using Fleck;
using Newtonsoft.Json;
using Pastel;
using RSND.Core.DbInternals;
using RSND.Core.Querying;
using RSND.Core.Querying.Queries;

View File

@ -2,5 +2,5 @@
public class Row
{
public Column[]? Columns;
public List<Column>? Columns;
}

View File

@ -3,5 +3,5 @@
public class Table
{
public string? Name;
public Row[]? Rows;
public List<Row>? Rows;
}

View File

@ -5,5 +5,5 @@ namespace RSND.Core.Querying.Queries;
public class AddQuery : Query
{
public string TableName { get; set; }
public Column[] Columns { get; set; }
public List<Column> Columns { get; set; }
}

View File

@ -4,12 +4,12 @@ namespace RSND.Core.Querying.Queries;
public class CreateTableQuery : Query
{
public CreateTableQuery(string tableName, Row[] rows)
public CreateTableQuery(string tableName, List<Row> rows)
{
TableName = tableName;
Rows = rows;
}
public string TableName { get; set; }
public Row[] Rows;
public List<Row>? Rows;
}

View File

@ -5,5 +5,4 @@ public class SetQuery : Query
public string TableName { get; set; }
public string Key { get; set; }
public string Value { get; set; }
public string NewValue { get; set; }
}

View File

@ -16,13 +16,13 @@ public static class RsndMain
Db.CreateTable(new Table
{
Name = "fooTable",
Rows = new []
Rows = new List<Row>
{
new Row
new()
{
Columns = new []
Columns = new List<Column>
{
new Column("test", "1")
new("test", "1")
}
}
}