@uql/sqlite
Advanced tools
Comparing version 0.4.55 to 0.4.56
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "0.4.55", | ||
"version": "0.4.56", | ||
"main": "index.js", | ||
@@ -20,3 +20,3 @@ "types": "index.d.ts", | ||
"peerDependencies": { | ||
"@uql/core": "^0.4.53" | ||
"@uql/core": "^0.4.55" | ||
}, | ||
@@ -26,3 +26,3 @@ "devDependencies": { | ||
"@types/sqlite3": "^3.1.7", | ||
"@uql/core": "^0.4.55", | ||
"@uql/core": "^0.4.56", | ||
"copyfiles": "^2.4.1", | ||
@@ -29,0 +29,0 @@ "rimraf": "^3.0.2", |
@@ -5,3 +5,3 @@ [](https://travis-ci.org/impensables/uql?branch=master) | ||
# :sun_with_face: Getting Started | ||
# Getting Started | ||
@@ -39,3 +39,3 @@ `uql` is a plug & play `ORM`, with declarative `JSON` syntax to query/update multiple data sources. Just declare what you want from the data source, and then `uql` will run fast and safe `SQL` (or `Mongo`) queries. | ||
## <a name="installation"></a>:battery: Installation | ||
## <a name="installation"></a> Installation | ||
@@ -107,3 +107,3 @@ 1. Install the core package: | ||
```json | ||
"target": "es6", // or a more recent ecmascript version | ||
"target": "es6", // or a more recent ecmascript version. | ||
"experimentalDecorators": true, | ||
@@ -113,3 +113,3 @@ "emitDecoratorMetadata": true | ||
## <a name="configuration"></a>:gear: Configuration | ||
## <a name="configuration"></a> Configuration | ||
@@ -134,3 +134,3 @@ Initialization should be done once (e.g. in one of the bootstrap files of your app). | ||
## <a name="entities"></a>:egg: Entities | ||
## <a name="entities"></a> Entities | ||
@@ -152,3 +152,3 @@ Take any dump class (aka DTO) and annotate it with the decorators from `'@uql/core/entity'`. | ||
/** | ||
* foreign-keys are really simple to specify | ||
* foreign-keys are really simple to specify. | ||
*/ | ||
@@ -170,3 +170,3 @@ @Field({ reference: () => User }) | ||
/** | ||
* `mappedBy` can be a callback or a string (callback is useful for auto-refactoring) | ||
* `mappedBy` can be a callback or a string (callback is useful for auto-refactoring). | ||
*/ | ||
@@ -234,3 +234,3 @@ @OneToOne({ entity: () => Profile, mappedBy: (profile) => profile.creatorId, cascade: true }) | ||
## <a name="declarative-transactions"></a>:speech_balloon: Declarative Transactions | ||
## <a name="declarative-transactions"></a> Declarative Transactions | ||
@@ -250,3 +250,3 @@ Both, _declarative_ and _programmatic_ transactions are supported, with the former you can just describe the scope of your transactions, with the later you have more flexibility (hence more responsibility). | ||
@Transactional() | ||
async confirmAction(confirmation: Confirmation, @InjectQuerier() querier?: Querier) { | ||
async confirmAction(confirmation: Confirmation, @InjectQuerier() querier?: Querier): Promise<void> { | ||
if (confirmation.type === 'register') { | ||
@@ -261,3 +261,3 @@ await querier.insertOne(User, { | ||
} | ||
await querier.updateOneById(Confirmation, confirmation.id, { status: CONFIRM_STATUS_VERIFIED }); | ||
await querier.updateOneById(Confirmation, confirmation.id, { status: 1 }); | ||
} | ||
@@ -271,3 +271,3 @@ } | ||
* and when you call `confirmAction` function, all the operations there | ||
* will (automatically) run inside a single transaction | ||
* will (automatically) run inside a single transaction. | ||
*/ | ||
@@ -277,3 +277,3 @@ await confirmationService.confirmAction(data); | ||
## <a name="programmatic-transactions"></a>:open_hands: Programmatic Transactions | ||
## <a name="programmatic-transactions"></a> Programmatic Transactions | ||
@@ -295,3 +295,3 @@ `uql` supports both, _declarative_ and _programmatic_ transactions, with the former you can just describe the scope of your transactions, with the later you have more flexibility (hence more responsibility). | ||
async function confirmAction(confirmation: Confirmation) { | ||
async function confirmAction(confirmation: Confirmation): Promise<void> { | ||
const querier = await getQuerier(); | ||
@@ -309,3 +309,3 @@ try { | ||
} | ||
await querier.updateOneById(Confirmation, confirmation.id, { status: CONFIRM_STATUS_VERIFIED }); | ||
await querier.updateOneById(Confirmation, confirmation.id, { status: 1 }); | ||
await querier.commitTransaction(); | ||
@@ -321,3 +321,3 @@ } catch (error) { | ||
## <a name="express"></a>:zap: Autogenerate REST APIs with Express | ||
## <a name="express"></a> Autogenerate REST APIs with Express | ||
@@ -354,11 +354,11 @@ A `express` plugin is provided to automatically generate REST APIs for your entities. | ||
// all entities will be automatically exposed unless | ||
// 'include' or 'exclude' options are provided | ||
// 'include' or 'exclude' options are provided. | ||
exclude: [Confirmation], | ||
// `query` callback allows to extend all then queries that are requested to the API, | ||
// so it is a good place to add additional filters to the queries (like for multi tenant apps) | ||
// so it is a good place to add additional filters to the queries (like for multi tenant apps). | ||
query<E>(entity: Type<E>, qm: Query<E>, req: Request): Query<E> { | ||
qm.$filter = { | ||
...qm.$filter, | ||
// ensure the user can only see the data that belongs to his company | ||
// ensure the user can only see the data that belongs to his company. | ||
companyId: req.identity.companyId, | ||
@@ -372,3 +372,3 @@ }; | ||
## <a name="client"></a>:cloud: Easily call the generated REST APIs from the Client | ||
## <a name="client"></a> Easily call the generated REST APIs from the Client | ||
@@ -394,3 +394,3 @@ A client plugin (for browser/mobile) is provided to easily consume the REST APIs from the frontend. | ||
// 'User' is an entity class | ||
// 'User' is an entity class. | ||
const userRepository = getRepository(User); | ||
@@ -397,0 +397,0 @@ |
22722