diff --git a/core/server/models/tag.js b/core/server/models/tag.js index a2356647d5..64581ff454 100644 --- a/core/server/models/tag.js +++ b/core/server/models/tag.js @@ -1,11 +1,20 @@ var Tag, Tags, + uuid = require('node-uuid'), Posts = require('./post').Posts, GhostBookshelf = require('./base'); Tag = GhostBookshelf.Model.extend({ tableName: 'tags', + hasTimestamps: true, + + defaults: function () { + return { + uuid: uuid.v4() + }; + }, + posts: function () { return this.belongsToMany(Posts); } diff --git a/core/server/models/user.js b/core/server/models/user.js index 11b9aa2fef..27cdd1a26e 100644 --- a/core/server/models/user.js +++ b/core/server/models/user.js @@ -1,7 +1,5 @@ var User, Users, - UserRole, -// UserRoles, _ = require('underscore'), uuid = require('node-uuid'), when = require('when'), @@ -13,10 +11,6 @@ var User, Role = require('./role').Role, Permission = require('./permission').Permission; -UserRole = GhostBookshelf.Model.extend({ - tableName: 'roles_users' -}); - function validatePasswordLength(password) { try { @@ -145,7 +139,7 @@ User = GhostBookshelf.Model.extend({ // Assign the userData to our created user so we can pass it back userData = addedUser; // Add this user to the admin role (assumes admin = role_id: 1) - return UserRole.add({role_id: 1, user_id: addedUser.id}); + return userData.roles().attach(1); }).then(function (addedUserRole) { // Return the added user as expected