@kohanajs/mixin-orm
Advanced tools
Comparing version 3.1.1 to 3.2.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [3.2.0](https://gitlab.com/kohana-js/controller-mixins/orm/compare/v3.1.1...v3.2.0) (2022-04-29) | ||
### Features | ||
* action_index support start and end query string ([c2b70d0](https://gitlab.com/kohana-js/controller-mixins/orm/commit/c2b70d06dfe8b4f37b53104f265ebd4ac6f8cfcb)) | ||
### [3.1.1](https://gitlab.com/kohana-js/controller-mixins/orm/compare/v3.1.0...v3.1.1) (2022-03-09) | ||
@@ -7,0 +14,0 @@ |
@@ -17,2 +17,16 @@ const { ControllerMixin } = require('@kohanajs/core-mvc'); | ||
static #formatDate(date) { | ||
let d = date, | ||
month = '' + (d.getMonth() + 1), | ||
day = '' + d.getDate(), | ||
year = d.getFullYear(); | ||
if (month.length < 2) | ||
month = '0' + month; | ||
if (day.length < 2) | ||
day = '0' + day; | ||
return [year, month, day].join('-'); | ||
} | ||
static init(state) { | ||
@@ -39,4 +53,13 @@ state.set(this.ORM_OPTIONS, new Map([ | ||
const offset = page * options.limit; | ||
const result = await ORM.readAll(model, { database, ...options, offset }); | ||
const start = client.request.query.start ?? '1970-1-1'; | ||
const end = this.#formatDate(new Date(new Date(client.request.query.end ?? '2999-12-31').getTime() + 86400000)); | ||
const result = await ORM.readWith(model, [ | ||
['', 'created_at', 'GREATER_THAN_EQUAL', `${start} 00:00:00+08:00`], | ||
['AND', 'created_at', 'LESS_THAN_EQUAL', `${end} 00:00:00+08:00`], | ||
] | ||
,{ database, ...options, offset } | ||
); | ||
state.set(this.COUNT, await ORM.count(model, { database })); | ||
@@ -43,0 +66,0 @@ state.set(this.INSTANCES, (!result) ? [] : [result].flat()); |
{ | ||
"name": "@kohanajs/mixin-orm", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21117
439