[英]Ember.js Model architecture with roles and states
I am currently diving into Ember.js. 我目前正在研究Ember.js。 I have started a new project which should handle todo tasks.
我已经开始了一个新的项目,应该可以处理待办事项。
However I have some problems in translating the database architecture and/or OOP architecture to an ember model architecture. 但是,在将数据库体系结构和/或OOP体系结构转换为余烬模型体系结构时,我遇到了一些问题。
What I would like to have is: 我想拥有的是:
A task which has the following attributes: 具有以下属性的任务:
id
title
state
('open', 'closed') state
(“打开”,“关闭”) editor
creator
createdAt
modifiedAt
The point were I stuck is: 我坚持的重点是:
I would be glad if anyone would have a suggestion for me since the Ember.js documentation only covers basic use cases and is lack of things like states. 我很高兴有人对我提出建议,因为Ember.js文档仅涵盖基本用例,并且缺少诸如状态之类的东西。
Well actually Ember is OOP, just to mention that first! 好吧,实际上Ember是OOP,首先要提到!
Now lets talk about your editor
/ editor
. 现在让我们谈谈您的
editor
editor
。 I would recommend to basically create another model person
, and then you could so something like this: 我建议基本上创建另一个模型
person
,然后可以这样:
creator: belongsTo('person'),
author: belongsTo('person'),
You don't need an inverse relationship so this will basically just work, as long you don't want to find all task
's one person has created or so. 您不需要逆向关系,因此只要您不想找到一个人创建的所有
task
,就可以正常工作。
For the state
you basically have three ways: 对于
state
您基本上有以下三种方式:
belongsTo
relationship. belongsTo
关系。 But this is not a good way if you want to execute different code on different states. state
. state
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.