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集合:成对出现 (情侣) ...
随机推荐
- Java数组常用API
java.util.Arrays Arrays.asList() 数组转换成列表 String[] strArray = {"zhang", "xue", &q ...
- Leetcode 526
class Solution { public: int countArrangement(int N) { vector<int> nums; ;i <= N;i++) nums. ...
- iOS-UI篇—简单的浏览器查看程序和Tomcat简单实现
#import "ViewController.h" @interface ViewController () @property (retain, nonatomic) NSAr ...
- SSH 本地端口转发
有时,绑定本地端口还不够,还必须指定数据传送的目标主机,从而形成点对点的"端口转发".为了区别后文的"远程端口转发",我们把这种情况称为"本地端口转发 ...
- 实现自己的ls命令
一步步实现,先看最简单的ls的指令: ls不带参数,直接打印文件名 dst.txt main10.c main11.c main12.c main13.c main14.c~ main15.c~ ma ...
- forget word out a~2
1● an 不,非,无 2● amphi 两个,两种 3● ad 做,加强:
- en_o out1
1● o əʊ ɒ ə ɔː ʌ ʊ: 2● oor ʊə ɔː 3● oo u u: 4● or ɜː ə ɔː 5● oar ore ɔː 6● ow əʊ aʊ ...
- 微信小程序wx.chooseImage和wx.previewImage的综合使用(图片上传不限制最多张数)
WXML: <view class="weui"> <view class="weui-uploader"> <view clas ...
- Java——使用File类递归遍历指定路劲下的所有文件
body, table{font-family: 微软雅黑} table{border-collapse: collapse; border: solid gray; border-width: 2p ...
- Python 数值计算库之-[Pandas](六)