- All schemas have been rewritten to a relational model - All services have been rewritten to accommodate the new data model - Adds idempotency keys to core endpoints allowing you to retry requests with no additional side effects - Adds staged jobs to avoid putting jobs in the queue when transactions abort - Adds atomic transactions to all methods with access to the data layer Co-authored-by: Oliver Windall Juhl <oliver@mrbltech.com>
20 lines
338 B
JavaScript
20 lines
338 B
JavaScript
import randomize from "randomatic";
|
|
|
|
class IdMap {
|
|
ids = {};
|
|
|
|
getId(key, prefix = "", length = 10) {
|
|
if (this.ids[key]) {
|
|
return this.ids[key];
|
|
}
|
|
|
|
const id = `${prefix && prefix + "_"}${randomize("Aa0", length)}`;
|
|
this.ids[key] = id;
|
|
|
|
return id;
|
|
}
|
|
}
|
|
|
|
const instance = new IdMap();
|
|
export default instance;
|