CRUD蓝图覆盖sails.js [英] CRUD blueprint overriding in sails.js

查看:155
本文介绍了CRUD蓝图覆盖sails.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这个封闭的问题:
https://github.com/balderdashy/sails/issues / 835

According to this closed issue in sails: https://github.com/balderdashy/sails/issues/835


CRUD蓝图覆盖
绝对是这个v0 .10

CRUD Blueprint Overrides "absolutely, this is coming in v0.10"

我想修改我的sailsjs服务中的蓝图,以允许命名根(消耗在ember中)。
目前,我不得不自定义每个控制器,我创建的操作大体上与蓝图中已有的重复。

I'd like to modify the blueprints in my sailsjs service to allow named roots (consuming in ember). Currently I'm having to customize every controller I create with actions that are largely duplicates of what is already in the blueprints.

我怀疑我可以移动现在我的控制器中的这个代码已经成为一个蓝图覆盖区域,但是我并不清楚在哪里放置该代码。

I suspect that I can move this code out of my controllers now and into a blueprints override area, but I'm not clear on where to put that code.

任何示例甚至只是一个指针

Any examples or even just a pointer to the relevant code in sails the .10 repo would be greatly appreciated.

推荐答案

要覆盖Sails v0.10中的蓝图,您将创建一个 api / blueprints 文件夹,并添加您的蓝图文件(例如 find.js 创建。 js 等)。您可以查看默认操作的代码在Sails蓝图挂钩开始。

To override blueprints in Sails v0.10, you create an api/blueprints folder and add your blueprint files (e.g. find.js, create.js, etc.) within. You can take a look at the code for the default actions in the Sails blueprints hook for a head start.

还支持添加自定义蓝图,但它们目前不会自动绑定到路由。如果您创建了一个 /blueprints/foo.js 文件,您可以在 /config/routes.js 文件(例如):

Adding custom blueprints is also supported, but they currently do not get bound to routes automatically. If you create a /blueprints/foo.js file, you can bind a route to it in your /config/routes.js file with (for example):

'GET /myRoute': {blueprint: 'foo'}

这篇关于CRUD蓝图覆盖sails.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆