Skip to content

v1.3.0 - Promise/Async API Support

Latest
Compare
Choose a tag to compare
@r-el r-el released this 11 Sep 09:23
1bc9080

New Features

Promise/Async API Support

  • Full async/await support - All CRUD methods now have Promise-based counterparts
  • Backward compatible - Original callback API remains unchanged
  • TypeScript integration - Updated type definitions for all async methods

New Methods

  • createAsync(), readAllAsync(), findByIdAsync()
  • findByAsync(), countAsync(), updateAsync()
  • deleteAsync(), deleteAllAsync(), writeAllAsync()

Examples

// New async API
const user = await db.createAsync({ name: 'John', age: 30 });
const users = await db.readAllAsync();
await db.updateAsync(user.id, { age: 31 });
await db.deleteAsync(user.id);

// Original callback API still works
db.create({ name: 'Jane' }, (err, user) => {
  console.log('Created:', user);
});

Installation

npm install json-file-crud

Breaking Changes

None - this release is fully backward compatible.