Files
kulupu/src/Poki.cs
2026-03-15 06:45:51 +00:00

68 lines
1.7 KiB
C#

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[] {};
}
}