Skip to content

Commit 2600917

Browse files
chore: wip
1 parent c4339bc commit 2600917

File tree

17 files changed

+476
-0
lines changed

17 files changed

+476
-0
lines changed

storage/framework/core/orm/src/generate.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,34 @@ export async function generateModelString(
876876
return model.map(modelItem => instance.parseResult(new ${modelName}Model(modelItem)))
877877
}
878878
879+
static skip(count: number): ${modelName}Model {
880+
const instance = new ${modelName}Model(null)
881+
882+
instance.selectFromQuery = instance.selectFromQuery.offset(count)
883+
884+
return instance
885+
}
886+
887+
skip(count: number): ${modelName}Model {
888+
this.selectFromQuery = this.selectFromQuery.offset(count)
889+
890+
return this
891+
}
892+
893+
static take(count: number): ${modelName}Model {
894+
const instance = new ${modelName}Model(null)
895+
896+
instance.selectFromQuery = instance.selectFromQuery.limit(count)
897+
898+
return instance
899+
}
900+
901+
take(count: number): this {
902+
this.selectFromQuery = this.selectFromQuery.limit(count)
903+
904+
return this
905+
}
906+
879907
async pluck<K extends keyof ${modelName}Model>(field: K): Promise<${modelName}Model[K][]> {
880908
if (this.hasSelect) {
881909
const model = await this.selectFromQuery.execute()

storage/framework/orm/src/models/AccessToken.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,34 @@ export class AccessTokenModel {
211211
return model.map(modelItem => instance.parseResult(new AccessTokenModel(modelItem)))
212212
}
213213

214+
static skip(count: number): AccessTokenModel {
215+
const instance = new AccessTokenModel(null)
216+
217+
instance.selectFromQuery = instance.selectFromQuery.offset(count)
218+
219+
return instance
220+
}
221+
222+
skip(count: number): AccessTokenModel {
223+
this.selectFromQuery = this.selectFromQuery.offset(count)
224+
225+
return this
226+
}
227+
228+
static take(count: number): AccessTokenModel {
229+
const instance = new AccessTokenModel(null)
230+
231+
instance.selectFromQuery = instance.selectFromQuery.limit(count)
232+
233+
return instance
234+
}
235+
236+
take(count: number): this {
237+
this.selectFromQuery = this.selectFromQuery.limit(count)
238+
239+
return this
240+
}
241+
214242
async pluck<K extends keyof AccessTokenModel>(field: K): Promise<AccessTokenModel[K][]> {
215243
if (this.hasSelect) {
216244
const model = await this.selectFromQuery.execute()

storage/framework/orm/src/models/Deployment.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,34 @@ export class DeploymentModel {
224224
return model.map(modelItem => instance.parseResult(new DeploymentModel(modelItem)))
225225
}
226226

227+
static skip(count: number): DeploymentModel {
228+
const instance = new DeploymentModel(null)
229+
230+
instance.selectFromQuery = instance.selectFromQuery.offset(count)
231+
232+
return instance
233+
}
234+
235+
skip(count: number): DeploymentModel {
236+
this.selectFromQuery = this.selectFromQuery.offset(count)
237+
238+
return this
239+
}
240+
241+
static take(count: number): DeploymentModel {
242+
const instance = new DeploymentModel(null)
243+
244+
instance.selectFromQuery = instance.selectFromQuery.limit(count)
245+
246+
return instance
247+
}
248+
249+
take(count: number): this {
250+
this.selectFromQuery = this.selectFromQuery.limit(count)
251+
252+
return this
253+
}
254+
227255
async pluck<K extends keyof DeploymentModel>(field: K): Promise<DeploymentModel[K][]> {
228256
if (this.hasSelect) {
229257
const model = await this.selectFromQuery.execute()

storage/framework/orm/src/models/Error.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,34 @@ export class ErrorModel {
201201
return model.map(modelItem => instance.parseResult(new ErrorModel(modelItem)))
202202
}
203203

204+
static skip(count: number): ErrorModel {
205+
const instance = new ErrorModel(null)
206+
207+
instance.selectFromQuery = instance.selectFromQuery.offset(count)
208+
209+
return instance
210+
}
211+
212+
skip(count: number): ErrorModel {
213+
this.selectFromQuery = this.selectFromQuery.offset(count)
214+
215+
return this
216+
}
217+
218+
static take(count: number): ErrorModel {
219+
const instance = new ErrorModel(null)
220+
221+
instance.selectFromQuery = instance.selectFromQuery.limit(count)
222+
223+
return instance
224+
}
225+
226+
take(count: number): this {
227+
this.selectFromQuery = this.selectFromQuery.limit(count)
228+
229+
return this
230+
}
231+
204232
async pluck<K extends keyof ErrorModel>(field: K): Promise<ErrorModel[K][]> {
205233
if (this.hasSelect) {
206234
const model = await this.selectFromQuery.execute()

storage/framework/orm/src/models/FailedJob.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,34 @@ export class FailedJobModel {
201201
return model.map(modelItem => instance.parseResult(new FailedJobModel(modelItem)))
202202
}
203203

204+
static skip(count: number): FailedJobModel {
205+
const instance = new FailedJobModel(null)
206+
207+
instance.selectFromQuery = instance.selectFromQuery.offset(count)
208+
209+
return instance
210+
}
211+
212+
skip(count: number): FailedJobModel {
213+
this.selectFromQuery = this.selectFromQuery.offset(count)
214+
215+
return this
216+
}
217+
218+
static take(count: number): FailedJobModel {
219+
const instance = new FailedJobModel(null)
220+
221+
instance.selectFromQuery = instance.selectFromQuery.limit(count)
222+
223+
return instance
224+
}
225+
226+
take(count: number): this {
227+
this.selectFromQuery = this.selectFromQuery.limit(count)
228+
229+
return this
230+
}
231+
204232
async pluck<K extends keyof FailedJobModel>(field: K): Promise<FailedJobModel[K][]> {
205233
if (this.hasSelect) {
206234
const model = await this.selectFromQuery.execute()

storage/framework/orm/src/models/Job.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,34 @@ export class JobModel {
201201
return model.map(modelItem => instance.parseResult(new JobModel(modelItem)))
202202
}
203203

204+
static skip(count: number): JobModel {
205+
const instance = new JobModel(null)
206+
207+
instance.selectFromQuery = instance.selectFromQuery.offset(count)
208+
209+
return instance
210+
}
211+
212+
skip(count: number): JobModel {
213+
this.selectFromQuery = this.selectFromQuery.offset(count)
214+
215+
return this
216+
}
217+
218+
static take(count: number): JobModel {
219+
const instance = new JobModel(null)
220+
221+
instance.selectFromQuery = instance.selectFromQuery.limit(count)
222+
223+
return instance
224+
}
225+
226+
take(count: number): this {
227+
this.selectFromQuery = this.selectFromQuery.limit(count)
228+
229+
return this
230+
}
231+
204232
async pluck<K extends keyof JobModel>(field: K): Promise<JobModel[K][]> {
205233
if (this.hasSelect) {
206234
const model = await this.selectFromQuery.execute()

storage/framework/orm/src/models/PaymentMethod.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,34 @@ export class PaymentMethodModel {
234234
return model.map(modelItem => instance.parseResult(new PaymentMethodModel(modelItem)))
235235
}
236236

237+
static skip(count: number): PaymentMethodModel {
238+
const instance = new PaymentMethodModel(null)
239+
240+
instance.selectFromQuery = instance.selectFromQuery.offset(count)
241+
242+
return instance
243+
}
244+
245+
skip(count: number): PaymentMethodModel {
246+
this.selectFromQuery = this.selectFromQuery.offset(count)
247+
248+
return this
249+
}
250+
251+
static take(count: number): PaymentMethodModel {
252+
const instance = new PaymentMethodModel(null)
253+
254+
instance.selectFromQuery = instance.selectFromQuery.limit(count)
255+
256+
return instance
257+
}
258+
259+
take(count: number): this {
260+
this.selectFromQuery = this.selectFromQuery.limit(count)
261+
262+
return this
263+
}
264+
237265
async pluck<K extends keyof PaymentMethodModel>(field: K): Promise<PaymentMethodModel[K][]> {
238266
if (this.hasSelect) {
239267
const model = await this.selectFromQuery.execute()

storage/framework/orm/src/models/Post.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,34 @@ export class PostModel {
205205
return model.map(modelItem => instance.parseResult(new PostModel(modelItem)))
206206
}
207207

208+
static skip(count: number): PostModel {
209+
const instance = new PostModel(null)
210+
211+
instance.selectFromQuery = instance.selectFromQuery.offset(count)
212+
213+
return instance
214+
}
215+
216+
skip(count: number): PostModel {
217+
this.selectFromQuery = this.selectFromQuery.offset(count)
218+
219+
return this
220+
}
221+
222+
static take(count: number): PostModel {
223+
const instance = new PostModel(null)
224+
225+
instance.selectFromQuery = instance.selectFromQuery.limit(count)
226+
227+
return instance
228+
}
229+
230+
take(count: number): this {
231+
this.selectFromQuery = this.selectFromQuery.limit(count)
232+
233+
return this
234+
}
235+
208236
async pluck<K extends keyof PostModel>(field: K): Promise<PostModel[K][]> {
209237
if (this.hasSelect) {
210238
const model = await this.selectFromQuery.execute()

storage/framework/orm/src/models/Product.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,34 @@ export class ProductModel {
211211
return model.map(modelItem => instance.parseResult(new ProductModel(modelItem)))
212212
}
213213

214+
static skip(count: number): ProductModel {
215+
const instance = new ProductModel(null)
216+
217+
instance.selectFromQuery = instance.selectFromQuery.offset(count)
218+
219+
return instance
220+
}
221+
222+
skip(count: number): ProductModel {
223+
this.selectFromQuery = this.selectFromQuery.offset(count)
224+
225+
return this
226+
}
227+
228+
static take(count: number): ProductModel {
229+
const instance = new ProductModel(null)
230+
231+
instance.selectFromQuery = instance.selectFromQuery.limit(count)
232+
233+
return instance
234+
}
235+
236+
take(count: number): this {
237+
this.selectFromQuery = this.selectFromQuery.limit(count)
238+
239+
return this
240+
}
241+
214242
async pluck<K extends keyof ProductModel>(field: K): Promise<ProductModel[K][]> {
215243
if (this.hasSelect) {
216244
const model = await this.selectFromQuery.execute()

storage/framework/orm/src/models/Project.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,34 @@ export class ProjectModel {
198198
return model.map(modelItem => instance.parseResult(new ProjectModel(modelItem)))
199199
}
200200

201+
static skip(count: number): ProjectModel {
202+
const instance = new ProjectModel(null)
203+
204+
instance.selectFromQuery = instance.selectFromQuery.offset(count)
205+
206+
return instance
207+
}
208+
209+
skip(count: number): ProjectModel {
210+
this.selectFromQuery = this.selectFromQuery.offset(count)
211+
212+
return this
213+
}
214+
215+
static take(count: number): ProjectModel {
216+
const instance = new ProjectModel(null)
217+
218+
instance.selectFromQuery = instance.selectFromQuery.limit(count)
219+
220+
return instance
221+
}
222+
223+
take(count: number): this {
224+
this.selectFromQuery = this.selectFromQuery.limit(count)
225+
226+
return this
227+
}
228+
201229
async pluck<K extends keyof ProjectModel>(field: K): Promise<ProjectModel[K][]> {
202230
if (this.hasSelect) {
203231
const model = await this.selectFromQuery.execute()

0 commit comments

Comments
 (0)