国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

node.js - 在NodeJS中如何通過相關(guān)的ORM庫來實現(xiàn)MySQL的表繼承關(guān)系?
大家講道理
大家講道理 2017-04-17 11:56:13
0
1
462

我在Quota上問過(How do I implement a MySQL inheritance relations with a Node.js database ORM (like sequelizejs)?),再這里重發(fā)一下,求有經(jīng)驗的各位指導(dǎo)下:

大體是這樣的,最近在寫個項目,做了下簡單的表設(shè)計,其中的部分如下:

(其中三個表共享id,id即是外鍵)之所以想這么弄的原因是,這個項目的內(nèi)容主體是project(不在上圖中),而一個項目可以屬于一個app也可以屬于user,為了統(tǒng)一,我希望每個項目都有一個唯一全局的名稱namespace/project_name,為了這個目的,我把appuser抽象出一個父類,也就是owner(或者直接換成namespace也可以),而且這樣后續(xù)我通過這個唯一的項目名稱查詢的時候也不需要預(yù)先做判斷這個namespace是應(yīng)用還是用戶。

但是在常見的這些 ORM 庫中沒有找到支持這么做的API,但是我又覺得這樣得設(shè)計應(yīng)該不是很少見,所以想知道大家一般是怎么處理的。

大家講道理
大家講道理

光陰似箭催人老,日月如移越少年。

reply all(1)
巴扎黑

Actually, you think this is an "inheritance" relationship, but it is essentially a "one-to-one one-way mapping", so just use Sequelize's hasOne to establish the relationship:

App.hasOne Owner
User.hasOne Owner

app_or_user.getOwner().then (owner) ->
  console.log owner.name

In addition, shouldn’t I go to StackOverflow? Why go to Quota?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template