当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript normalizr.Schema类代码示例

本文整理汇总了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;未经允许,请勿转载。