• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript normalizr.Schema类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中normalizr.Schema的典型用法代码示例。如果您正苦于以下问题:TypeScript Schema类的具体用法?TypeScript Schema怎么用?TypeScript Schema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Schema类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: Schema

import {Schema, arrayOf} from 'normalizr';
import phone from './phone';


const contact = new Schema('contacts',{
    idAttribute: '_id'
});

contact.define({phones: arrayOf(phone)});

export default contact;
开发者ID:DaveMBush,项目名称:MEA2N_CRUD_Reference_App,代码行数:11,代码来源:contact.ts


示例2: Schema

import { normalize, Schema, arrayOf, valuesOf } from "normalizr";
export var article = new Schema("articles");
export var comment = new Schema("comments");
export var user = new Schema("users");
article.define({
	get_comments : arrayOf(comment),
	get_author : user,
});

comment.define({
	get_author : user,
	get_article : article,
});

user.define({
	get_articles : arrayOf(article),
	get_comments : arrayOf(comment),
});
开发者ID:joewood,项目名称:refluxion,代码行数:18,代码来源:test-model.normalizr.ts


示例3: Schema

/// <reference path="normalizr.d.ts" />

import { normalize, Schema, arrayOf, unionOf, valuesOf } from 'normalizr';

// First, define a schema for our entities:

const article1 = new Schema('articles');
const user1 = new Schema('users');

// Then we define nesting rules:

article1.define({
    author: user1,
    contributors: arrayOf(user1)
});

// Now we can use this schema in our API response handlers:

const ServerActionCreators = {
    // These are two different XHR endpoints with different response schemas.
    // We can use the schema objects defined earlier to express both of them:

    receiveOneArticle(response: any) {
        // Here, the response is an object containing data about one article.
        // Passing the article schema as second parameter to normalize() lets it
        // correctly traverse the response tree and gather all entities:

        // BEFORE:
        // {
        //   id: 1,
        //   title: 'Some Article',
开发者ID:1drop,项目名称:DefinitelyTyped,代码行数:31,代码来源:normalizr-tests.ts


示例4: Schema

import {Schema, arrayOf} from 'normalizr';
import {generateSlug} from './schemas_helpers';

// Default options
let getOptions = (overrides = {}) => {
  let options = {
    idAttribute: generateSlug
  };
  return Object.assign(options, overrides);
}

/**
 * Schema setup for Case
 */
export const caseSchema = new Schema('case', getOptions());
/**
 * Schema setup for Interactions (reply, message, draft)
 */
export const interactionSchema = new Schema('interaction', getOptions());
export const draftSchema = new Schema('draft', getOptions());
export const messageSchema = new Schema('message', getOptions());
export const replySchema = new Schema('reply', getOptions());
/**
 * Schema setup for Customer
 */
export const customerSchema = new Schema('customer', getOptions());
export const userSchema = new Schema('user', getOptions());

export const caseChangesSchema = new Schema('changes', getOptions());

开发者ID:jasonaden,项目名称:restore,代码行数:29,代码来源:schemas.ts


示例5: Record

import { Schema } from 'normalizr'
import { List, Map, Record } from 'immutable'

import {userSchema, IUser} from '../user/user.schema'

export const PostRecord = Record({
  id: null,
  title: null,
  body: null,
  user: null,
  deleting: false
})

export const postSchema = new Schema('posts')

postSchema.define({
  user: userSchema
})


export interface IPost {
  id: string
  title: string
  body: string
  userId: number
  user: any
}

export interface IPosts extends Map<String, any> {
  result: List<Number>
  entities: {
开发者ID:AmbientIT,项目名称:ng2Experiments,代码行数:31,代码来源:post.schema.ts



注:本文中的normalizr.Schema类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript nova-base.validate类代码示例发布时间:2022-05-25
下一篇:
TypeScript normalizr.normalize函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap