當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Schema.define方法代碼示例

本文整理匯總了TypeScript中normalizr.Schema.define方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Schema.define方法的具體用法?TypeScript Schema.define怎麽用?TypeScript Schema.define使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在normalizr.Schema的用法示例。


在下文中一共展示了Schema.define方法的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

 */
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());


interactionSchema.define({
  case: caseSchema
});

customerSchema.define({
  cases: arrayOf(caseSchema)
});

caseSchema.define({
  _embedded: {
    customer: customerSchema, 
    draft: draftSchema,
    message: messageSchema, 
    replies: arrayOf(interactionSchema),
    foober: customerSchema
  },  
});
開發者ID:jasonaden,項目名稱:restore,代碼行數:31,代碼來源:schemas.ts

示例5: Record

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: {
    posts: Map<Number, IPost>,
開發者ID:AmbientIT,項目名稱:ng2Experiments,代碼行數:31,代碼來源:post.schema.ts


注:本文中的normalizr.Schema.define方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。