-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d0f2ef
commit b53c58a
Showing
20 changed files
with
172 additions
and
16 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
examples/social-network/app/controllers/categorizations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Controller } from 'lux-framework'; | ||
|
||
class CategorizationsController extends Controller { | ||
params = [ | ||
'postId', | ||
'tagId' | ||
]; | ||
} | ||
|
||
export default CategorizationsController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Controller } from 'lux-framework'; | ||
|
||
class TagsController extends Controller { | ||
params = [ | ||
'name' | ||
]; | ||
} | ||
|
||
export default TagsController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Model } from 'lux-framework'; | ||
|
||
class Categorization extends Model { | ||
static belongsTo = { | ||
tag: { | ||
inverse: 'posts' | ||
}, | ||
|
||
post: { | ||
inverse: 'tags' | ||
} | ||
}; | ||
} | ||
|
||
export default Categorization; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import { Model } from 'lux-framework'; | ||
|
||
/* TODO: Add support for self-join on users through a join table. | ||
* https://github.com/postlight/lux/issues/76 | ||
*/ | ||
class Friendship extends Model { | ||
static belongsTo = { | ||
follower: { | ||
model: 'user', | ||
inverse: 'followers', | ||
}, | ||
|
||
followee: { | ||
model: 'user', | ||
inverse: 'followees', | ||
} | ||
}; | ||
} | ||
|
||
export default Friendship; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ class Reaction extends Model { | |
}, | ||
|
||
post: { | ||
inverse: 'reaction' | ||
inverse: 'reactions' | ||
}, | ||
|
||
user: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Model } from 'lux-framework'; | ||
|
||
class Tag extends Model { | ||
static hasMany = { | ||
posts: { | ||
inverse: 'tags', | ||
through: 'categorization' | ||
} | ||
}; | ||
} | ||
|
||
export default Tag; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
examples/social-network/app/serializers/categorizations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Serializer } from 'lux-framework'; | ||
|
||
class CategorizationsSerializer extends Serializer { | ||
hasOne = [ | ||
'post', | ||
'tag' | ||
]; | ||
} | ||
|
||
export default CategorizationsSerializer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import { Serializer } from 'lux-framework'; | ||
|
||
class FriendshipsSerializer extends Serializer { | ||
|
||
hasOne = [ | ||
'followee', | ||
'follower' | ||
]; | ||
} | ||
|
||
export default FriendshipsSerializer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Serializer } from 'lux-framework'; | ||
|
||
class TagsSerializer extends Serializer { | ||
attributes = [ | ||
'name' | ||
]; | ||
|
||
hasMany = [ | ||
'posts' | ||
]; | ||
} | ||
|
||
export default TagsSerializer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
examples/social-network/db/migrate/2016061214092135-create-tags.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export function up(schema) { | ||
return schema.createTable('tags', table => { | ||
table.increments('id'); | ||
table.string('name'); | ||
table.timestamps(); | ||
|
||
table.index([ | ||
'id', | ||
'name', | ||
'created_at', | ||
'updated_at' | ||
]); | ||
}); | ||
} | ||
|
||
export function down(schema) { | ||
return schema.dropTable('tags'); | ||
} |
20 changes: 20 additions & 0 deletions
20
examples/social-network/db/migrate/2016061214112168-create-categorizations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function up(schema) { | ||
return schema.createTable('categorizations', table => { | ||
table.increments('id'); | ||
table.integer('post_id'); | ||
table.integer('tag_id'); | ||
table.timestamps(); | ||
|
||
table.index([ | ||
'id', | ||
'post_id', | ||
'tag_id', | ||
'created_at', | ||
'updated_at' | ||
]); | ||
}); | ||
} | ||
|
||
export function down(schema) { | ||
return schema.dropTable('categorizations'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters