mirror of
https://github.com/appy-one/acebase.git
synced 2026-05-25 22:01:21 -06:00
- autoGrow now also works with one-leaf trees - allow entry ext_block to grow & move into leaf free ext_data space
29 lines
No EOL
980 B
JavaScript
29 lines
No EOL
980 B
JavaScript
const { AceBase, ID } = require('../src/index');
|
|
|
|
const db = new AceBase('custom-test');
|
|
db.ready(async () => {
|
|
|
|
// Temp custom test for #112, using non-random data for easier (reproducible) debugging
|
|
|
|
const exists = await db.ref('collection').exists();
|
|
let updates = {};
|
|
if (!exists) {
|
|
for (let i = 0; i < 2000; i++) {
|
|
updates[ID.generate()] = { letter: String.fromCharCode(97 + Math.floor(Math.random() * 26)) };
|
|
}
|
|
|
|
// create non-indexed collection
|
|
await db.ref("collection").update(updates);
|
|
}
|
|
else {
|
|
const snap = await db.ref('collection').get();
|
|
updates = snap.val();
|
|
}
|
|
|
|
// create indexed collection
|
|
const indexes = await db.indexes.get();
|
|
await Promise.all(indexes.map(index => db.indexes.delete(index.fileName)));
|
|
await db.ref("sort_indexed").remove();
|
|
await db.indexes.create("sort_indexed", "letter");
|
|
await db.ref("sort_indexed").update(updates);
|
|
}); |