Skip to content

Commit 5bbaaa3

Browse files
chore: wip
1 parent cd1f2ab commit 5bbaaa3

File tree

14 files changed

+30
-13
lines changed

14 files changed

+30
-13
lines changed

app/Models/User.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default {
3737
index: 'UserIndexOrmAction',
3838
show: 'UserShowOrmAction',
3939
store: 'UserStoreAction',
40+
destroy: 'UserDestroyOrmAction',
4041
},
4142
},
4243

storage/framework/core/router/src/router.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,16 @@ export class Router implements RouterInterface {
302302
// if fails, return validation error
303303
let requestInstance
304304

305+
console.log('actionModule', actionModule)
306+
305307
if (actionModule.default.requestFile) {
306308
requestInstance = await findRequestInstance(actionModule.default.requestFile)
307309
} else {
308-
if (modulePath.includes('OrmAction')) {
309-
requestInstance = await extractModelRequest(modulePath)
310-
} else requestInstance = await extractDefaultRequest(modulePath)
310+
requestInstance = await extractDefaultRequest(modulePath)
311311
}
312312

313+
console.log(actionModule.default.requestFile)
314+
313315
try {
314316
return await actionModule.default.handle(requestInstance)
315317
} catch (error: any) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Action } from '@stacksjs/actions'
2+
import type { UserRequestType } from '../../types/requests'
3+
import User from '../src/models/User'
4+
5+
export default new Action({
6+
name: 'User Destroy',
7+
description: 'User Destroy ORM Action',
8+
method: 'DELETE',
9+
async handle(request: UserRequestType) {
10+
const id = request.getParam('id')
11+
12+
const model = await User.findOrFail(Number(id))
13+
14+
model.delete()
15+
16+
return 'Model deleted!'
17+
},
18+
})

storage/framework/orm/Actions/UserIndexOrmAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export default new Action({
77
description: 'User Index ORM Action',
88
method: 'GET',
99
async handle(request: UserRequestType) {
10-
return await User.get()
10+
return await User.all()
1111
},
1212
})

storage/framework/orm/routes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ await route.get(
1111
)
1212

1313
await route.post('users', '/Users/glennmichaeltorregosa/Documents/Projects/stacks/app/Actions/UserStoreAction.ts')
14+
15+
await route.delete(
16+
'users/{id}',
17+
'/Users/glennmichaeltorregosa/Documents/Projects/stacks/storage/framework/orm/Actions/UserDestroyOrmAction.ts',
18+
)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ export class AccessTokenModel {
122122

123123
const instance = new this(null)
124124

125-
// Check if soft deletes are enabled
126125
if (instance.softDeletes) {
127126
query = query.where('deleted_at', 'is', null)
128127
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ export class DeploymentModel {
131131

132132
const instance = new this(null)
133133

134-
// Check if soft deletes are enabled
135134
if (instance.softDeletes) {
136135
query = query.where('deleted_at', 'is', null)
137136
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ export class PostModel {
116116

117117
const instance = new this(null)
118118

119-
// Check if soft deletes are enabled
120119
if (instance.softDeletes) {
121120
query = query.where('deleted_at', 'is', null)
122121
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export class ProjectModel {
117117

118118
const instance = new this(null)
119119

120-
// Check if soft deletes are enabled
121120
if (instance.softDeletes) {
122121
query = query.where('deleted_at', 'is', null)
123122
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ export class ReleaseModel {
108108

109109
const instance = new this(null)
110110

111-
// Check if soft deletes are enabled
112111
if (instance.softDeletes) {
113112
query = query.where('deleted_at', 'is', null)
114113
}

0 commit comments

Comments
 (0)