-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0c9ba2
commit 66396e2
Showing
7 changed files
with
19 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
blueprints/resource/files/app/actions/__plural.name__/create.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import ApplicationAction from '../application'; | ||
import <%= singular.className %> from '../../models/<%= singular.dasherized %>'; | ||
|
||
export default class Create<%= singular.className %> extends ApplicationAction { | ||
|
||
async respond({ body }) { | ||
let post = await this.db.create('<%= singular.dasherized %>', body).save(); | ||
this.render(201, post); | ||
let <%= singular.camelCased %> = await <%= singular.className %>.create(body); | ||
this.render(201, <%= singular.camelCased %>); | ||
} | ||
|
||
} |
5 changes: 3 additions & 2 deletions
5
blueprints/resource/files/app/actions/__plural.name__/destroy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import ApplicationAction from '../application'; | ||
import <%= singular.className %> from '../../models/<%= singular.dasherized %>'; | ||
|
||
export default class List<%= plural.className %> extends ApplicationAction { | ||
|
||
async respond() { | ||
return await this.db.all('<%= singular.dasherized %>'); | ||
return await <%= singular.className %>.all(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import ApplicationAction from '../application'; | ||
import <%= singular.className %> from '../../models/<%= singular.dasherized %>'; | ||
|
||
export default class Show<%= singular.className %> extends ApplicationAction { | ||
|
||
async respond({ params }) { | ||
return this.db.find('<%= singular.dasherized %>', params.id); | ||
return await <%= singular.className %>.find(params.id); | ||
} | ||
|
||
} |
7 changes: 4 additions & 3 deletions
7
blueprints/resource/files/app/actions/__plural.name__/update.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import ApplicationAction from '../application'; | ||
import <%= singular.className %> from '../../models/<%= singular.dasherized %>'; | ||
|
||
export default class Update<%= singular.className %> extends ApplicationAction { | ||
|
||
async respond({ params, body }) { | ||
let post = await this.db.find('<%= singular.dasherized %>', params.id); | ||
Object.assign(post, body); | ||
return await post.save(); | ||
let <%= singular.camelCased %> = await <%= singular.className %>.find(params.id); | ||
Object.assign(<%= singular.camelCased %>, body); | ||
return await <%= singular.camelCased %>.save(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { attr /* , hasOne, hasMany */ } from 'denali'; | ||
import { /* attr, hasOne, hasMany */ } from 'denali'; | ||
import ApplicationModel from './application'; | ||
|
||
export default class <%= singular.className %> extends ApplicationModel { | ||
|
||
// static title = attr('text'); | ||
static schema = {}; | ||
|
||
} |