init
This commit is contained in:
67
src/Poki.cs
Normal file
67
src/Poki.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using Npgsql;
|
||||
|
||||
public class Poki {
|
||||
NpgsqlConnection _connection;
|
||||
|
||||
Account _account;
|
||||
int _id;
|
||||
string[] _names;
|
||||
Poki[]? _parentPoki, _childPoki;
|
||||
bool _fronting, _frontable;
|
||||
string[]? _tags;
|
||||
|
||||
|
||||
public Poki(
|
||||
NpgsqlConnection connection,
|
||||
Account account,
|
||||
string[] names,
|
||||
Poki[]? parentPoki = null, Poki[]? childPoki = null,
|
||||
bool fronting = false, bool frontable = true,
|
||||
string[]? tags = null
|
||||
) {
|
||||
_connection = connection;
|
||||
_account = account;
|
||||
_names = names;
|
||||
_parentPoki = parentPoki; _childPoki = childPoki;
|
||||
_fronting = fronting; _frontable = frontable;
|
||||
_tags = tags;
|
||||
|
||||
NpgsqlCommand command = new("""
|
||||
INSERT INTO poki VALUES (
|
||||
($1),
|
||||
DEFAULT,
|
||||
($2),
|
||||
($3),
|
||||
($4),
|
||||
($5),
|
||||
($6),
|
||||
($7)
|
||||
)
|
||||
""", connection) {
|
||||
Parameters = {
|
||||
new() { Value = account.KUID },
|
||||
new() { Value = names },
|
||||
new() { Value = parentPoki },
|
||||
new() { Value = childPoki },
|
||||
new() { Value = fronting },
|
||||
new() { Value = frontable },
|
||||
new() { Value = tags }
|
||||
}
|
||||
};
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
|
||||
command = new("""
|
||||
SELECT currval('poki_id_seq')
|
||||
""", connection);
|
||||
|
||||
#pragma warning disable CS8605
|
||||
_id = (int) command.ExecuteScalar();
|
||||
#pragma warning disable CS8605
|
||||
}
|
||||
|
||||
public static Poki[] GetPokiByName(string name) {
|
||||
return new Poki[] {};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user