一张参考图

说明

从上图我们可以方便的看出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 定义

  1. const schema = {
  2. // default properties
  3. _id: {
  4. type: String,
  5. optional: true,
  6. canRead: ["guests"]
  7. },
  8. createdAt: {
  9. type: Date,
  10. optional: true,
  11. canRead: ["guests"],
  12. onCreate: ({ newDocument, currentUser }) => {
  13. return new Date();
  14. }
  15. },
  16. userId: {
  17. type: String,
  18. optional: true,
  19. canRead: ["guests"],
  20. resolveAs: {
  21. fieldName: "user",
  22. type: "User",
  23. resolver: (movie, args, context) => {
  24. return context.Users.findOne(
  25. { _id: movie.userId },
  26. {
  27. fields: context.Users.getViewableFields(
  28. context.currentUser,
  29. context.Users
  30. )
  31. }
  32. );
  33. },
  34. addOriginalField: true
  35. }
  36. },
  37. // custom properties
  38. name: {
  39. label: "Name",
  40. type: String,
  41. optional: true,
  42. canRead: ["guests"],
  43. canCreate: ["members"],
  44. canUpdate: ["members"]
  45. },
  46. year: {
  47. label: "Year",
  48. type: String,
  49. optional: true,
  50. canRead: ["guests"],
  51. canCreate: ["members"],
  52. canUpdate: ["members"]
  53. },
  54. review: {
  55. label: "Review",
  56. type: String,
  57. optional: true,
  58. control: "textarea",
  59. canRead: ["guests"],
  60. canCreate: ["members"],
  61. canUpdate: ["members"]
  62. }
  63. };
  • 创建collection

    实际上上就是graphql api schema 定义以及解析处理

  1. const Movies = createCollection({
  2. typeName: "Movie",
  3. schema,
  4. resolvers,
  5. mutations
  6. });

参考资料

http://docs.vulcanjs.org/schemas.html

 
 
 
 

vulcanjs schemas&& collections的更多相关文章

  1. Java基础Map接口+Collections工具类

    1.Map中我们主要讲两个接口 HashMap  与   LinkedHashMap (1)其中LinkedHashMap是有序的  怎么存怎么取出来 我们讲一下Map的增删改查功能: /* * Ma ...

  2. Java基础Map接口+Collections

    1.Map中我们主要讲两个接口 HashMap  与   LinkedHashMap (1)其中LinkedHashMap是有序的  怎么存怎么取出来 我们讲一下Map的增删改查功能: /* * Ma ...

  3. 计算机程序的思维逻辑 (54) - 剖析Collections - 设计模式

    上节我们提到,类Collections中大概有两类功能,第一类是对容器接口对象进行操作,第二类是返回一个容器接口对象,上节我们介绍了第一类,本节我们介绍第二类. 第二类方法大概可以分为两组: 接受其他 ...

  4. 2DToolkit官方文档中文版打地鼠教程(三):Sprite Collections 精灵集合

    这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...

  5. 计算机程序的思维逻辑 (53) - 剖析Collections - 算法

    之前几节介绍了各种具体容器类和抽象容器类,上节我们提到,Java中有一个类Collections,提供了很多针对容器接口的通用功能,这些功能都是以静态方法的方式提供的. 都有哪些功能呢?大概可以分为两 ...

  6. Collection和Collections的区别?

    Collection 是接口(Interface),是集合类的上层接口. Collections是类(Class),集合操作的工具类,服务于Collection框架.它是一个算法类,提供一系列静态方法 ...

  7. Collections.shuffle

    1.Collections.shuffler 最近有个需求是生成十万级至百万级的所有随机数,最简单的思路是一个个生成,生成新的时候排重,但是这样时间复杂度是o(n^2),网上看了几个博客的解决方法都不 ...

  8. 集合工具类:collections

    collection与collections的关系? public class Collectionsextends Object collection与collections没有直接的关系,但是与集 ...

  9. Map集合及与Collection的区别、HashMap和HashTable的区别、Collections、

    特点:将键映射到值的对象,一个映射不能包含重复的键,每个键最多只能映射到一个值. Map集合和Collection集合的区别 Map集合:成对出现 (情侣)                       ...

随机推荐

  1. Java数组常用API

    java.util.Arrays Arrays.asList() 数组转换成列表 String[] strArray = {"zhang", "xue", &q ...

  2. Leetcode 526

    class Solution { public: int countArrangement(int N) { vector<int> nums; ;i <= N;i++) nums. ...

  3. iOS-UI篇—简单的浏览器查看程序和Tomcat简单实现

    #import "ViewController.h" @interface ViewController () @property (retain, nonatomic) NSAr ...

  4. SSH 本地端口转发

    有时,绑定本地端口还不够,还必须指定数据传送的目标主机,从而形成点对点的"端口转发".为了区别后文的"远程端口转发",我们把这种情况称为"本地端口转发 ...

  5. 实现自己的ls命令

    一步步实现,先看最简单的ls的指令: ls不带参数,直接打印文件名 dst.txt main10.c main11.c main12.c main13.c main14.c~ main15.c~ ma ...

  6. forget word out a~2

        1● an 不,非,无   2● amphi     两个,两种     3● ad 做,加强:  

  7. en_o out1

    1● o əʊ ɒ ə ɔː ʌ ʊ:     2● oor ʊə ɔː   3● oo u u:     4● or ɜː ə ɔː   5● oar ore ɔː   6● ow   əʊ aʊ ...

  8. 微信小程序wx.chooseImage和wx.previewImage的综合使用(图片上传不限制最多张数)

    WXML: <view class="weui"> <view class="weui-uploader"> <view clas ...

  9. Java——使用File类递归遍历指定路劲下的所有文件

    body, table{font-family: 微软雅黑} table{border-collapse: collapse; border: solid gray; border-width: 2p ...

  10. Python 数值计算库之-[Pandas](六)