Commit Graph

35 Commits

Author SHA1 Message Date
Samarpan Bhattacharya d29bec72a8 feat: add capability for insert multiple rows in single query
Signed-off-by: Samarpan Bhattacharya <this.is.samy@gmail.com>
2022-11-01 15:47:02 -04:00
Rifa Achrinza 2691470504 fix: remove `geo.d.ts`
Use of Template Literal Types broke support for older LB4 projects.

Temporarily removing it would have minimal impact as:

1. It was only introduced in the last release
2. It was not usable as-is due to wrong export location

fixes: https://github.com/loopbackio/loopback-datasource-juggler/issues/1909

Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
2022-02-22 09:14:38 +00:00
Rifa Achrinza 816b948ab0 feat: add built-in model property types typdef
Added typdef for:
- Any
- JSON
- Text
- GeoPoint
- DateString

Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
2021-09-22 19:32:13 +08:00
Miroslav Bajtoš f13d50ea3f
types: support no-SQL styles of `ds.execute`
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2020-07-28 10:01:34 +02:00
khlilturki97@gmail.com b1cd7eff5c
types: add `DataSource.definitions` property 2020-07-27 09:50:33 +02:00
Miroslav Bajtoš 4c53abad32
types: allow no `models` argument for automigrate
Fix type definitions to allow zero-argument invocation of
the following database migration methods:
  - `DataSource.automigrate()`
  - `DataSource.autoupdate()`

Implementation-wise, when no model names are specified, then ALL models
attached to the datasource are migrated.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2020-05-12 15:39:47 +02:00
Miroslav Bajtoš 7292d206e5
types: make DataSource.stop compatible with LB4
Change the return value of `DataSource.stop()` from `Promise<void>`
to `void | PromiseLike<void>` to avoid breaking existing LoopBack 4
applications, where DataSource subclasses are scaffolded with
`stop(): ValueOrPromise<void>`.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2020-04-28 08:27:49 +02:00
Miroslav Bajtoš c83f82d5a0
feat: implement DataSource.stop()
Implement `stop` as an alias for `disconnect`. This way LB4 applications
don't have to include custom `stop` implementation in every datasource
file.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2020-04-23 16:20:44 +02:00
Hage Yaapa 2946c5b489 chore: improve Listener signature
Improved Listener signature so it can accept callback or promise.
2020-03-05 14:30:24 +05:30
Miroslav Bajtoš b01cd74b19
fixup! improve comment for `this` & static members
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2020-03-02 13:04:01 +01:00
Miroslav Bajtoš c7b88e9b8e
Add ObserverMixin members to ModelBase typings
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2020-03-02 11:54:48 +01:00
Miroslav Bajtoš 92654f646b
Add default generic arg value to `Listener` type
The changes introduced by dcfda58 may break existing consumers
of our typings. This commit fixes this problem by adding a default
value to the recently introduced generic argument of `Listener` type.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2020-03-02 11:26:01 +01:00
Hage Yaapa dcfda58fda feat: add OperationHookContext interface
Added OperationHookContext interface.

Signed-off-by: Hage Yaapa <hage.yaapa@in.ibm.com>
2020-02-28 21:47:27 +05:30
Diana Lau 251ced811b
Update copyright year and CODEOWNERS (#1818)
* chore: update CODEOWNERS

* chore: update copyright years
2020-01-21 13:12:14 -05:00
Miroslav Bajtoš abdd5675b0
Fix typo introduced by 19048cd7
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-12-06 10:35:19 +01:00
Miroslav Bajtoš 19048cd716
Fix Promise/Callback variants in datasource types
Remove usage of `PromiseOrVoid`, it makes it difficult to consume
the API via `await`. For each async method, define multiple variants
to correctly describe what's returned when a callback arg was provided
(`void`) and what's returned when called with no callback
(`Promise<T>`).

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-12-05 16:30:22 +01:00
Raymond Feng 1e8b8a041b Fix typescript typing for DataSource.getModel
See https://github.com/strongloop/loopback-next/pull/3722
2019-09-19 09:25:24 -07:00
Biniam Admikew e3c276720f fix: use only promises for beginTransaction
Co-authored-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-07-19 10:30:10 -04:00
Miroslav Bajtoš 78c5b12740
feat: add DataSource.deleteAllModels() API
When writing tests, for performance reasons we often want to reuse
the same data-source instance for many tests suites. At the same time,
we want to keep such test suites independent and allow them to reuse
the same model name for different model classes.

Juggler does support redefinition of a model with the same name.

This change is adding a new API called that allows tests to remove all
old models before creating new ones. This API would be typically
called from a `before` hook.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-07-18 17:56:41 +02:00
Biniam Admikew 1ed385e393 feat: add beginTransaction API on datasource
add beginTransaction method which calls begin
method from the Transaction class which in turn
calls the connector's beginTransaction method if
it supports transactions.

Co-Authored-By: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-06-28 12:58:50 -04:00
Biniam Admikew 39555a010a Revert "chore: expose beginTransaction API"
This reverts commit 313925a5e7.
2019-06-25 09:08:11 -04:00
Biniam Admikew 313925a5e7 chore: expose beginTransaction API 2019-06-24 17:16:31 -04:00
Miroslav Bajtoš df4d89279a
Fix types to describe native Promise
In version 4.0.0, we switched from Bluebird to native Promises.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-06-13 15:24:01 +02:00
Agnes Lin de4718d5b8 chore: update copyrights years (#1737) 2019-05-08 11:45:37 -04:00
biniam 4b705b127c fix: update typescript declarations 2019-01-31 00:29:35 -05:00
Miroslav Bajtoš 81fc722b72
Improve Model type definitions
Define two new types: ModelSettings and ModelProperties to describe the
objects describing model properties and settings.

Add static property `base` and static method `extend` to the definition
of `ModelBase` class.

Add property `defaultModelBaseClass` to `ModelBuilder` class definition.

Fix `PropertyDefinition` interface: remove `name`, add optional `id`.
2019-01-24 16:27:40 +01:00
Miroslav Bajtoš fda332d60b
feat: dataSource.execute(cmd, args, opts, cb)
Implement a new helper API for calling connector's "execute" method
in a promise-friendly way.
2018-12-07 14:51:14 +01:00
shimks 1e59918c11 Add EventEmitter type info to DataSource type 2018-07-25 15:13:54 -04:00
Raymond Feng 535b000195 fix: update TypeScript declaration for KV 2018-07-16 10:11:54 -07:00
Miroslav Bajtoš 6f3675b13c
fixup! address code review comments 2018-06-29 08:35:22 +02:00
Miroslav Bajtoš 548379ca2a
Fix type definitions for PersistedModel API
Callback's first argument is an optional Error now. Was: required `any`.

PersistedModel methods return `PersistedModel` now. Before this change,
methods were returning `PersistedData` (`PersistedModel | AnyObject`).
The problem with `AnyObject` is that it does not contain any
`PersistedModel` instance data and cannot be assigned to functions
expecting `Partial<PersistedModel>`. As a result, consumers of this API
were forced to either cast the result to `PersistedModel` (which feels
wrong) or deal with the `AnyObject` case (which never happen at
runtime).

Fix definition of `ModelData<T>` to `T | Partial<T>`. Before this
change, `ModelData` allowed any values not related to the actual
model at all, for example arrays.
2018-06-28 13:09:47 +02:00
Raymond Feng 5a66f9ad72 Fix datasource state management
Use case:
1. Configure a datasource with lazyConnect = true
2. Do NOT start the DB
3. Start the app
4. Send first request and it fails to connnect to the DB
5. Start the DB
5. Requests are now served correctly
2018-05-22 10:46:45 -07:00
Raymond Feng d31c43bc09 Remove node ref 2018-05-11 09:09:31 -07:00
Raymond Feng 63f8b3b323 Fix typescript definitions to be compatible with LB4 2018-05-10 10:19:15 -07:00
Raymond Feng 77a2c9ab3b Add typescript type definitions 2018-05-09 12:47:27 -07:00