ezdb 0.2.0
A declarative SQL library similary to Spring Data
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
EzDb
EzDb is a database system similar to Spring Data JPA. It currently supports both SQLite and an in-memory database.
Usage
Here is a simple example that explains the usage of EzDb:
import ezdb;
// Define the entity representing a single record in a table.
struct SomeEntity
{
@primaryKey
int id;
string someValue;
}
// A repository that functions as the interface to a repository.
interface SomeRepository : Repository!SomeEntity
{
}
// Create an instance for the repository.
auto db = makeRepository!SomeRepository;
scope(exit) db.close();
// Create an entity and save it.
SomeEntity newEntity;
newEntity.someValue = "hello, world!";
SomeEntity savedEntity = db.save(newEntity);
Unit-testing
A system requiring a database can easily be tested using the mockRepository
function.
import ezdb;
unittest
{
auto db = mockRepository!SomeRepository;
SomeEntity mockEntity;
mockEntity.someValue = "hello, test!";
db.save(mockEntity);
// Do the rest of the test here
}
Other functionality
All supported operations on a database can currently be found in the package ezdb.repository
.
Check out the documentation!
- Registered by Sebastiaan de Schaetzen
- 0.2.0 released 3 years ago
- seeseemelk/ezdb
- MIT
- Copyright © 2020, Sebastiaan de Schaetzen
- Authors:
- Dependencies:
- d2sqlite3, optional
- Versions:
-
0.5.0 2020-Jun-18 0.4.1 2020-Apr-09 0.4.0 2020-Apr-09 0.3.0 2020-Apr-07 0.2.0 2020-Feb-09 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
119 downloads total
-
- Score:
- 0.6
- Short URL:
- ezdb.dub.pm