AngularJs와 함께 BreezeJs를 사용하여 MongoDB 백엔드가있는 웹 API와 통신하고 있으며 상속성이있는 복잡한 유형의 배열이 필요한 문서 중 하나의 메타 데이터를 정의하는 데 문제가 있습니다.BreezeJs - 상속 메타 데이터가있는 복합 유형의 배열
이는 MongoDB의 문서
{
"_id" : ObjectId("53f2f0f117166f1e6898cc32"),
"Name" : "SectionContainer1",
"Sections" : [{
"_t" : "SectionA",
"Title" : "sdf sdaf dsfsdfdsfsdfds"
}, {
"_t" : "SectionB",
"Title" : "sdf sdaf dsfsdfdsfsdfds"
}, {
"_t" : "SectionC",
"_id" : "53f38e1317166f196025849b",
"Title" : "sdf sdaf dsfsdfdsfsdfds"
}]
}
및 클래스 구조는
public class SectionContainer
{
public ObjectId Id{get;set;}
public string Name{get;set;}
public List<BaseSection> Sections{get;set;}
}
public class BaseSection
{
public string Title{get;set;}
}
public class SectionA : BaseSection
{
...
}
public class SectionB : BaseSection
{
...
}
public class SectionC : BaseSection
{
...
}
이것은 내가 불행하게도 바람이하지 않는 것 BreezeJs
(function() {
'use strict';
angular
.module('app')
.factory('metadataFactory', ['breeze', metadataFactory]);
function metadataFactory(breeze) {
var addType, DATE, DT, helper, ID;
// The metadata definition service
return {
fillMetadataStore: fillMetadataStore
};
/*** Implementation ***/
function fillMetadataStore(metadataStore, serviceName) {
init(metadataStore, serviceName);
addTypes();
}
function addTypes() {
addType({
name: 'SectionContainer',
dataProperties: {
id: { isPartOfKey: true },
name: { nullOk: true },
sections: { complexTypeName: "BaseSection", hasMany: true }
}
});
addType({
name: 'BaseSection',
isAbstract: true,
isComplexType: true,
dataProperties: {
id: { isPartOfKey: true },
title: { nullOk: true }
}
});
addType({
name: 'SectionA',
isComplexType: true,
baseTypeName: "BaseSection",
dataProperties: {
id: { isPartOfKey: true },
title: { nullOk: true },
}
});
addType({
name: 'SectionB',
isComplexType: true,
baseTypeName: "BaseSection",
dataProperties: {
id: { isPartOfKey: true },
title: { nullOk: true },
}
});
addType({
name: 'SectionC',
isComplexType: true,
baseTypeName: "BaseSection",
dataProperties: {
id: { isPartOfKey: true },
title: { nullOk: true },
}
});
}
// Initialize the metdataFactory with convenience fns and variables
function init(metadataStore, serviceName) {
var store = metadataStore; // the metadataStore that we'll be filling
// 'Identity' is the default key generation strategy for this app
var keyGen = breeze.AutoGeneratedKeyType.Identity;
// Breeze Labs: breeze.metadata.helper.js
// https://github.com/IdeaBlade/Breeze/blob/master/Breeze.Client/Scripts/Labs/breeze.metadata-helper.js
// The helper reduces data entry by applying common conventions
// and converting common abbreviations (e.g., 'type' -> 'dataType')
helper = new breeze.config.MetadataHelper(namespace, keyGen);
helper.addDataService(store, serviceName);
// addType - make it easy to add the type to the store using the helper
addType = function (type) { return helper.addTypeToStore(store, type); };
// DataTypes we'll be using
DT = breeze.DataType;
DATE = DT.DateTime;
ID = DT.Int32;
}
}
})();
에서 할 노력하고 무엇인가 복잡한 유형의 상속을 허용하고 데이터가 MongoDB에서 포맷되는 방식으로 인해 e 섹션은 자체 엔티티가 아닙니다. Breeze에서 이와 같은 데이터를 표현할 수 있습니까? 그렇다면 어떻게해야합니까? Breeze.js 워드 프로세서에서 촬영