OSDN Git Service

initial commit
[open-pdm-light/PartList.git] / PartsList / PartsList / app / models / PartsListDb.scala
1 package models
2 import org.squeryl.Schema
3 import org.squeryl.PrimitiveTypeMode._
4 object PartsListDb extends Schema{
5   val parts = table[Part]
6   val atachs = table[Atach]
7   val projects = table[Project]
8   val users = table[User]
9   val notifies = table[Notify]
10   val replies = table[Reply]
11   
12   on( parts )( p => declare(
13     // varchar(20)にしてみる
14     p.name is ( dbType( "varchar(20)" ) )
15   ) )
16   
17   val partRelations = manyToManyRelation(parts, parts).via[PartRelation]((pp,cp,pr) => (pp.id === pr.parentId, cp.id === pr.childId))
18   val projectMembers = manyToManyRelation(projects, users).via[ProjectMembers]((p, u, pm) => (p.id === pm.projectId, u.id === pm.userId))
19   val partsAtache = oneToManyRelation(parts, atachs).via((p, a) => p.id === a.foreignId)
20   val projectParts = oneToManyRelation(projects, parts).via((pr, p) => pr.id === p.projectId)
21   val partsNotifies = oneToManyRelation(parts, notifies).via((p, n) => p.id === n.partId)
22   val userNotifies = oneToManyRelation(users, notifies).via((u, n) => u.id === n.announceId)
23   val NotifyReplies = oneToManyRelation(notifies, replies).via((n, r) => n.id === r.notifyId)
24   val userReplies = oneToManyRelation(users, replies).via((u, r) => u.id === r.replyUserId)
25   val replyRelations = oneToManyRelation(replies, replies).via((pre, cre) => pre.id === cre.replyId )
26 }