Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
glennmichael123 committed Jan 2, 2025
1 parent 598fac8 commit fa1b249
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 34 deletions.
8 changes: 4 additions & 4 deletions storage/framework/core/orm/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1732,10 +1732,10 @@ export async function generateModelString(
if (!model)
return undefined
${relationStringThisMany}
${relationStringThisBelong}
const data = new ${modelName}Model(model as ${modelName}Type)
const result = await this.mapWith(model)
const data = new ${modelName}Model(result as ${modelName}Type)
cache.getOrSet(\`${formattedModelName}:\${id}\`, JSON.stringify(model))
Expand Down Expand Up @@ -2204,7 +2204,7 @@ export async function generateModelString(
if (!model)
return undefined
const instance = new ${modelName}Model(null)
const result = await instance.mapWith(model)
Expand Down
4 changes: 3 additions & 1 deletion storage/framework/orm/src/models/AccessToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export class AccessTokenModel {
if (!model)
return undefined

const data = new AccessTokenModel(model as AccessTokenType)
const result = await this.mapWith(model)

const data = new AccessTokenModel(result as AccessTokenType)

cache.getOrSet(`accesstoken:${id}`, JSON.stringify(model))

Expand Down
4 changes: 2 additions & 2 deletions storage/framework/orm/src/models/Deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ export class DeploymentModel {
if (!model)
return undefined

model.user = await this.userBelong()
const result = await this.mapWith(model)

const data = new DeploymentModel(model as DeploymentType)
const data = new DeploymentModel(result as DeploymentType)

cache.getOrSet(`deployment:${id}`, JSON.stringify(model))

Expand Down
4 changes: 3 additions & 1 deletion storage/framework/orm/src/models/Error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ export class ErrorModel {
if (!model)
return undefined

const data = new ErrorModel(model as ErrorType)
const result = await this.mapWith(model)

const data = new ErrorModel(result as ErrorType)

cache.getOrSet(`error:${id}`, JSON.stringify(model))

Expand Down
6 changes: 2 additions & 4 deletions storage/framework/orm/src/models/PaymentMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,9 @@ export class PaymentMethodModel {
if (!model)
return undefined

model.transactions = await this.transactionsHasMany()

model.user = await this.userBelong()
const result = await this.mapWith(model)

const data = new PaymentMethodModel(model as PaymentMethodType)
const data = new PaymentMethodModel(result as PaymentMethodType)

cache.getOrSet(`paymentmethod:${id}`, JSON.stringify(model))

Expand Down
4 changes: 2 additions & 2 deletions storage/framework/orm/src/models/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ export class PostModel {
if (!model)
return undefined

model.user = await this.userBelong()
const result = await this.mapWith(model)

const data = new PostModel(model as PostType)
const data = new PostModel(result as PostType)

cache.getOrSet(`post:${id}`, JSON.stringify(model))

Expand Down
4 changes: 3 additions & 1 deletion storage/framework/orm/src/models/Product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export class ProductModel {
if (!model)
return undefined

const data = new ProductModel(model as ProductType)
const result = await this.mapWith(model)

const data = new ProductModel(result as ProductType)

cache.getOrSet(`product:${id}`, JSON.stringify(model))

Expand Down
4 changes: 3 additions & 1 deletion storage/framework/orm/src/models/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export class ProjectModel {
if (!model)
return undefined

const data = new ProjectModel(model as ProjectType)
const result = await this.mapWith(model)

const data = new ProjectModel(result as ProjectType)

cache.getOrSet(`project:${id}`, JSON.stringify(model))

Expand Down
4 changes: 3 additions & 1 deletion storage/framework/orm/src/models/Release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export class ReleaseModel {
if (!model)
return undefined

const data = new ReleaseModel(model as ReleaseType)
const result = await this.mapWith(model)

const data = new ReleaseModel(result as ReleaseType)

cache.getOrSet(`release:${id}`, JSON.stringify(model))

Expand Down
4 changes: 3 additions & 1 deletion storage/framework/orm/src/models/Subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export class SubscriberModel {
if (!model)
return undefined

const data = new SubscriberModel(model as SubscriberType)
const result = await this.mapWith(model)

const data = new SubscriberModel(result as SubscriberType)

cache.getOrSet(`subscriber:${id}`, JSON.stringify(model))

Expand Down
4 changes: 3 additions & 1 deletion storage/framework/orm/src/models/SubscriberEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export class SubscriberEmailModel {
if (!model)
return undefined

const data = new SubscriberEmailModel(model as SubscriberEmailType)
const result = await this.mapWith(model)

const data = new SubscriberEmailModel(result as SubscriberEmailType)

cache.getOrSet(`subscriberemail:${id}`, JSON.stringify(model))

Expand Down
4 changes: 2 additions & 2 deletions storage/framework/orm/src/models/Subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ export class SubscriptionModel {
if (!model)
return undefined

model.user = await this.userBelong()
const result = await this.mapWith(model)

const data = new SubscriptionModel(model as SubscriptionType)
const data = new SubscriptionModel(result as SubscriptionType)

cache.getOrSet(`subscription:${id}`, JSON.stringify(model))

Expand Down
4 changes: 3 additions & 1 deletion storage/framework/orm/src/models/Team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ export class TeamModel {
if (!model)
return undefined

const data = new TeamModel(model as TeamType)
const result = await this.mapWith(model)

const data = new TeamModel(result as TeamType)

cache.getOrSet(`team:${id}`, JSON.stringify(model))

Expand Down
6 changes: 2 additions & 4 deletions storage/framework/orm/src/models/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,9 @@ export class TransactionModel {
if (!model)
return undefined

model.user = await this.userBelong()

model.payment_method = await this.paymentMethodBelong()
const result = await this.mapWith(model)

const data = new TransactionModel(model as TransactionType)
const data = new TransactionModel(result as TransactionType)

cache.getOrSet(`transaction:${id}`, JSON.stringify(model))

Expand Down
10 changes: 2 additions & 8 deletions storage/framework/orm/src/models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,9 @@ export class UserModel {
if (!model)
return undefined

model.deployments = await this.deploymentsHasMany()

model.subscriptions = await this.subscriptionsHasMany()

model.payment_methods = await this.paymentMethodsHasMany()
const result = await this.mapWith(model)

model.transactions = await this.transactionsHasMany()

const data = new UserModel(model as UserType)
const data = new UserModel(result as UserType)

cache.getOrSet(`user:${id}`, JSON.stringify(model))

Expand Down

0 comments on commit fa1b249

Please sign in to comment.