Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
fraciString
✓ import { fraciString } from 'fraci'
✗ const { fraciString } = require('fraci')
ESM only; named export for string-based fractional indexing.
fraciBinary
✓ import { fraciBinary } from 'fraci'
✗ import FraciBinary from 'fraci'
ESM only; named export for binary-based fractional indexing using Uint8Array.
defineDrizzleFraci
✓ import { defineDrizzleFraci } from 'fraci/drizzle'
✗ import { defineDrizzleFraci } from 'fraci'
Subpath export for Drizzle integration; not available from main entry.
definePrismaFraci
✓ import { definePrismaFraci } from 'fraci/prisma'
✗ import { definePrismaFraci } from 'fraci'
Subpath export for Prisma integration; not available from main entry.
BASE62
✓ import { BASE62 } from 'fraci'
Predefined base constant for alphanumeric characters.
Demonstrates setting up fractional indexing with Drizzle ORM: define a string-based fraci instance, integrate it into a table schema, and insert a new ordered task with conflict regeneration.
import { BASE62, fraciString, type FractionalIndexOf } from 'fraci';
import { defineDrizzleFraci, drizzleFraci } from 'fraci/drizzle';
const tasksFraci = fraciString({
brand: 'tasks.fi',
lengthBase: BASE62,
digitBase: BASE62,
});
export const tasks = sqliteTable(
'tasks',
{
id: integer('id').primaryKey({ autoIncrement: true }),
title: text('title').notNull(),
fi: text('fi').notNull().$type<FractionalIndexOf<typeof tasksFraci>>(),
userId: integer('user_id').notNull(),
},
(t) => [uniqueIndex('tasks_user_id_fi_idx').on(t.userId, t.fi)],
);
export const fiTasks = defineDrizzleFraci(
tasksFraci,
tasks,
tasks.fi,
{ userId: tasks.userId },
{ id: tasks.id },
);
const tfi = drizzleFraci(db, fiTasks);
const indices = await tfi.indicesForLast({ userId: 1 });
for (const fi of tfi.generateKeyBetween(...indices)) {
try {
return await db.insert(tasks).values({ title: 'New Task', fi, userId: 1 }).returning().get();
} catch (error) {
if (isIndexConflictError(error)) continue;
throw error;
}
}
Errors
Common errors & fixes
Cannot find module 'fraci/drizzle' or its corresponding type declarations.
The import path is incorrect or the package is not installed correctly; subpath exports may not be resolved by some bundlers.
fixEnsure fraci version 0.18.0 is installed, and your bundler/tsconfig supports subpath exports (requires Node >=16, tsconfig.json with moduleResolution: 'node16' or 'bundler').
Type 'string' is not assignable to type 'FractionalIndexOf<...>'
The column type is not correctly using $type<FractionalIndexOf<...>> from the fraci instance.
fixApply .$type<FractionalIndexOf<typeof yourFraciInstance>>() to the column definition.
No overload matches this call... 'defineDrizzleFraci' expects ...
The arguments to defineDrizzleFraci are mismatched: order matters or properties are missing/invalid.
fixCheck the signature: defineDrizzleFraci(fraciInstance, table, fiColumn, groupColumns, cursorColumns). All arguments must be provided.
Audit
Dependencies
drizzle-ormoptionalOptional peer dependency for Drizzle ORM integration
@prisma/clientoptionalOptional peer dependency for Prisma ORM integration