New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need actual documentation #48
Comments
Edit: Please use the NPM package named class InMemoryDatabase {
constructor() {
this.data = {
participant: [],
stage: [],
group: [],
round: [],
match: [],
match_game: []
};
}
setData(data) {
this.data = data;
}
makeFilter(partial) {
return (entry) => {
let result = true;
for (const [key, value] of Object.entries(partial)) {
result = result && entry[key] === value;
}
return result;
};
}
reset() {
this.data = {
participant: [],
stage: [],
group: [],
round: [],
match: [],
match_game: []
};
}
async insert(table, arg) {
let id = this.data[table].length;
if (!Array.isArray(arg)) {
try {
this.data[table].push({ id, ...arg });
}
catch (error) {
return -1;
}
return id;
}
try {
arg.map(object => {
this.data[table].push({ id: id++, ...object });
});
} catch (error) {
return false;
}
return true;
}
async select(table, arg) {
try {
if (arg === undefined) return this.data[table];
if (typeof arg === "number") return this.data[table][arg];
return this.data[table].filter(this.makeFilter(arg)) || null;
}
catch (error) {
return null;
}
}
async update(table, arg, value) {
if (typeof arg === 'number') {
try {
this.data[table][arg] = value;
return true;
}
catch (error) {
return false;
}
}
const values = this.data[table].filter(this.makeFilter(arg));
if (!values) return false;
values.forEach(v => {
let existing = this.data[table][v.id];
for (const key in value) {
existing[key] = value[key];
}
this.data[table][v.id] = existing;
});
return true;
}
async delete(table, filter) {
const values = this.data[table];
if (!values) return false;
const predicate = this.makeFilter(filter);
const negativeFilter = (value) => !predicate(value);
this.data[table] = values.filter(negativeFilter);
return true;
}
} |
Asked here too... #28 |
And do this: #52 |
Fix the README (powers of two needed?, etc.) |
Reference to this, or maybe just the schema: #111 |
Interesting to add in the seeding section: #123 (comment) About this also: #59 |
Also this: brackets-manager.js/test/update.spec.js Lines 608 to 610 in 6319cb4
|
Needs a word about this decision: #133 |
Interesting questions here: #144 Should be answered in the docs |
More documentation would be great. I love the libraries but dislike having to read the code of each class to figure out what everything does. I'm still chasing what the seeding options mean, as well as the proper options for round robin. |
Hey, that's true. In the meantime, what you better need to read are the unit tests. Not the code. The unit tests document the code 😉 |
You are correct, unit tests were a lot easier. That doesn't change the fact it would be nice to have finished Documentation for such a wonderful group of projects :) |
As said here, the library needs more documentation and examples of implementations for the CRUD interface.
The text was updated successfully, but these errors were encountered: