All checks were successful
Deploy datapack to dev / Build (push) Successful in 6s
72 lines
1.8 KiB
Plaintext
72 lines
1.8 KiB
Plaintext
@lazy //takes name of table. metadata must already exist.
|
|
function createTable(name) {
|
|
logger(2, database.createTable, "Creating table: $name");
|
|
Array.forEach(
|
|
"ferdinland:ferdinland",
|
|
"database.tables.$name.fields",
|
|
()=>{tellraw @a {"storage":"ferdinland:ferdinland", "nbt":"database.tables.$name.fields[0]"};}
|
|
);
|
|
}
|
|
|
|
class database {
|
|
@add(__load__)
|
|
function __init__() {}
|
|
|
|
@add(this.__init__)
|
|
function schema() {}
|
|
|
|
@add(this.schema)
|
|
function tables.myTable() {
|
|
::database.tables.myTable.name = "myTable";
|
|
::database.tables.myTable.fields = ["one", "two"];
|
|
createTable(myTable);
|
|
}
|
|
}
|
|
|
|
class database.benchmark {
|
|
function arrayTest1.setup() {
|
|
::database.test.arrayTest1.array = [];
|
|
Hardcode.repeat(
|
|
indexString="[index]",
|
|
start=0,
|
|
stop=500,
|
|
function=() => {
|
|
::database.test.arrayTest1.array << {id: Hardcode.calc([index]+1), string: "entryHardcode.calc([index]+1)"};
|
|
}
|
|
);
|
|
}
|
|
function arrayTest1.print() {
|
|
tellraw @a {"nbt":"database.test.arrayTest1.array","storage":"ferdinland:ferdinland"};
|
|
}
|
|
function arrayTest1.clean() {
|
|
::database.test.arrayTest1.array.del();
|
|
::temp.arrayTest1.del();
|
|
}
|
|
function arrayTest1.run() {
|
|
::temp.arrayTest1 = ::database.test.arrayTest1.array;
|
|
Array.forEach(
|
|
"ferdinland:ferdinland",
|
|
"temp.arrayTest1",
|
|
() => {
|
|
if (String.isEqual("ferdinland:ferdinland", "temp.arrayTest1[0].string", "entry500")) {
|
|
logger(1, database.benchmark.arrayTest1.run, "found: entry500");
|
|
}
|
|
if (String.isEqual("ferdinland:ferdinland", "temp.arrayTest1[0].string", "entry500")) {
|
|
return;
|
|
}
|
|
}
|
|
);
|
|
::temp.arrayTest1.del();
|
|
}
|
|
|
|
|
|
function arrayTest2.setup() {
|
|
::database.test.arrayTest2.arrays = [];
|
|
::database.test.arrayTest2.index = [];
|
|
}
|
|
function arrayTest2.clean() {
|
|
}
|
|
function arrayTest2.run() {
|
|
}
|
|
}
|