vulcanjs schemas&& collections
一张参考图
说明
从上图我们可以方便的看出schmea 能做的事情
- Generate a GraphQL equivalent of your schema to control your GraphQL API.(生成 graphql api)
- Control permissions for accessing and modifying data.(访问控制)
- Generate forms on the client.(client 以及表单生成)
- Validate form contents on submission.(数据校验)
- Auto-generate paginated, searchable datatables.(自动生成分页,查询)
- Auto-generate smart cards for displaying individual documents.(智能卡生成)
- Add callbacks on document insert or edit.(数据添加,编辑时候的回掉)
参考例子
- schema
类似graphql-yogo 以及graphql-js 的schema 定义
const schema = {
// default properties
_id: {
type: String,
optional: true,
canRead: ["guests"]
},
createdAt: {
type: Date,
optional: true,
canRead: ["guests"],
onCreate: ({ newDocument, currentUser }) => {
return new Date();
}
},
userId: {
type: String,
optional: true,
canRead: ["guests"],
resolveAs: {
fieldName: "user",
type: "User",
resolver: (movie, args, context) => {
return context.Users.findOne(
{ _id: movie.userId },
{
fields: context.Users.getViewableFields(
context.currentUser,
context.Users
)
}
);
},
addOriginalField: true
}
},
// custom properties
name: {
label: "Name",
type: String,
optional: true,
canRead: ["guests"],
canCreate: ["members"],
canUpdate: ["members"]
},
year: {
label: "Year",
type: String,
optional: true,
canRead: ["guests"],
canCreate: ["members"],
canUpdate: ["members"]
},
review: {
label: "Review",
type: String,
optional: true,
control: "textarea",
canRead: ["guests"],
canCreate: ["members"],
canUpdate: ["members"]
}
};
- 创建collection
实际上上就是graphql api schema 定义以及解析处理
const Movies = createCollection({
typeName: "Movie",
schema,
resolvers,
mutations
});
参考资料
http://docs.vulcanjs.org/schemas.html
vulcanjs schemas&& collections的更多相关文章
- Java基础Map接口+Collections工具类
1.Map中我们主要讲两个接口 HashMap 与 LinkedHashMap (1)其中LinkedHashMap是有序的 怎么存怎么取出来 我们讲一下Map的增删改查功能: /* * Ma ...
- Java基础Map接口+Collections
1.Map中我们主要讲两个接口 HashMap 与 LinkedHashMap (1)其中LinkedHashMap是有序的 怎么存怎么取出来 我们讲一下Map的增删改查功能: /* * Ma ...
- 计算机程序的思维逻辑 (54) - 剖析Collections - 设计模式
上节我们提到,类Collections中大概有两类功能,第一类是对容器接口对象进行操作,第二类是返回一个容器接口对象,上节我们介绍了第一类,本节我们介绍第二类. 第二类方法大概可以分为两组: 接受其他 ...
- 2DToolkit官方文档中文版打地鼠教程(三):Sprite Collections 精灵集合
这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...
- 计算机程序的思维逻辑 (53) - 剖析Collections - 算法
之前几节介绍了各种具体容器类和抽象容器类,上节我们提到,Java中有一个类Collections,提供了很多针对容器接口的通用功能,这些功能都是以静态方法的方式提供的. 都有哪些功能呢?大概可以分为两 ...
- Collection和Collections的区别?
Collection 是接口(Interface),是集合类的上层接口. Collections是类(Class),集合操作的工具类,服务于Collection框架.它是一个算法类,提供一系列静态方法 ...
- Collections.shuffle
1.Collections.shuffler 最近有个需求是生成十万级至百万级的所有随机数,最简单的思路是一个个生成,生成新的时候排重,但是这样时间复杂度是o(n^2),网上看了几个博客的解决方法都不 ...
- 集合工具类:collections
collection与collections的关系? public class Collectionsextends Object collection与collections没有直接的关系,但是与集 ...
- Map集合及与Collection的区别、HashMap和HashTable的区别、Collections、
特点:将键映射到值的对象,一个映射不能包含重复的键,每个键最多只能映射到一个值. Map集合和Collection集合的区别 Map集合:成对出现 (情侣) ...
随机推荐
- 3.5 MIPS体系结构
计算机组成 3 指令系统体系结构 3.5 MIPS体系结构 MIPS是精简指令系统的代表,采用了与X86相反的设计理念,并引领了精简指令系统的潮流,那就让我们一起来看一看这究竟是怎么一回事. 要探讨M ...
- java克隆机制
看了下面博客就很明白了 http://www.cnblogs.com/Qian123/p/5710533.html#_label0 java对象创建方式有三种: 1.通过new对象 2.通过java克 ...
- 1月11日Atom 插件安装。
查看已安装的Atom插件(前提:已经安装Atom) 打开终端 输入apm ls命令,回车. 未安装任何插件时,显示如下 Built-in Atom packages (89) ...此处省略... / ...
- exec可以用来执行语句的
set @sql='select * from '+@table print @sql exec(@sql)
- page上BeanId与ActionType中的ParameterId
今天遇到一件有意思的异常. 一个基于EO的VO在页面加载进来之后就CreateRow了一行数据,主键HeaderId也相应的插入了值,但是在保存的时候,老是报HeaderId不能为空的异常. 经查,页 ...
- en_e out1
1◆e i: ə ɜː e i 2◆ eu 3◆ ew 4◆ ei ey eu ew 5◆ eer ue 6◆ ee u: u 7◆ er ɜː 8◆ ere ie ue ...
- poj2895
题解: splay,维护当前第k大 并查集维护当前集合 合并x,y时,del(num[x]),del(num[y]),insert(num[x]+num[y]) 代码: #include<cst ...
- 关于apicloud ios自定义模块引用第三方framework not found for architecture armv7
1 .自定义模块 新建模块必须是静态库 2.使用的第三方framework 必须要把 .h文件开放出来 3.编译要用 真机模式 (上传模块以后,自定义load要编译,用生成的二维码调试) 4. 添加监 ...
- python安装大型包时出现错误Unable to find vcvarsall.bat
在windows平台上,据说是安装cpython编写的包时会出现Unable to find vcvarsall.bat这种错误,缺失编译C的环境或组件吧,所以这个包就安装不成功,这个时候简单的方法就 ...
- hdu 1556 Color the ball (线段树+代码详解)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...