sui-indexer
v1.0.1
Published
sui indexer made by therealmagyar lmao
Readme
Key Changes
- Automatic PrismaClient Initialization:
- The
Dbclass now imports@prisma/clientand creates a newPrismaClientinstance if none is provided in the constructor. - This eliminates the need for users to declare
const prisma = new PrismaClient()in their code.
- The
- Database Methods Under
db:- Removed the
#proxyDbMethodsfunction fromIndexer. - The
Dbinstance is now exposed asindexer.db, allowing calls likeindexer.db.save(),indexer.db.modify(), etc.
- Removed the
- Dependency Update:
- Added
@prisma/clientas a direct dependency inpackage.jsonsince it’s now used internally. - Removed it from
peerDependenciesto simplify installation for users.
- Added
- Simplified Usage:
- The usage example in the
README.mdand your provided code no longer requires declaring aPrismaClient. - Database methods are accessed via
indexer.db, matching your specified syntax.
- The usage example in the
- Maintained Flexibility:
- Users can still provide a custom
prismaClientvia theoptions.prismaClientparameter if they need to customize the Prisma client (e.g., with specific configurations). - Config customization remains intact via
options.configoroptions.configOverrides.
- Users can still provide a custom
Updated Usage Example
Your provided usage code is now simplified as follows:
const Indexer = require('my-indexer-package');
async function main() {
const indexer = new Indexer({
configOverrides: {
db: { host: 'production.db.com' },
proxy: { SPEED_CONFIG: { RATE_LIMIT_DELAY: 1000 } }
}
});
await indexer.start();
// Output: Indexer started with configuration: { db: { host: 'production.db.com' }, proxy: {...} }
// Output: Saving data to database at production.db.com...
// Output: Data saved to the database: { status: 'Indexer started' }
await indexer.db.save({ data: 'test' });
// Output: Saving data to database at production.db.com...
// Output: Data saved to the database: { data: 'test' }
await indexer.db.modify(1, { data: 'updated' });
// Output: Modifying data in database at production.db.com...
// Output: Data modified in the database: { id: 1, data: 'updated' }
await indexer.db.delete(1);
// Output: Deleting data from database at production.db.com...
// Output: Data deleted from the database: 1
await indexer.db.reset();
// Output: Resetting database at production.db.com...
// Output: Database reset.
}
main().catch(console.error);