Browse Source

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

master
j4ck 2 years ago
parent
commit
72cf566049
  1. 17
      RSND/Core/Database.cs
  2. 1
      RSND/Core/DbClient.cs
  3. 2
      RSND/Core/DbInternals/Row.cs
  4. 2
      RSND/Core/DbInternals/Table.cs
  5. 2
      RSND/Core/Querying/BaseQuery.cs
  6. 2
      RSND/Core/Querying/Queries/AddQuery.cs
  7. 4
      RSND/Core/Querying/Queries/CreateTableQuery.cs
  8. 1
      RSND/Core/Querying/Queries/SetQuery.cs
  9. 8
      RSND/RsndMain.cs

17
RSND/Core/Database.cs

@ -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()

1
RSND/Core/DbClient.cs

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

2
RSND/Core/DbInternals/Row.cs

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

2
RSND/Core/DbInternals/Table.cs

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

2
RSND/Core/Querying/BaseQuery.cs

@ -9,6 +9,6 @@ public class BaseQuery
{
Type = type;
}
public string Type { get; set; }
}

2
RSND/Core/Querying/Queries/AddQuery.cs

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

4
RSND/Core/Querying/Queries/CreateTableQuery.cs

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

1
RSND/Core/Querying/Queries/SetQuery.cs

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

8
RSND/RsndMain.cs

@ -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")
}
}
}

Loading…
Cancel
Save