Я ищу, чтобы внедрить систему сообщений в стиле facebook (потоковые сообщения) в мой сайт.Схема схемы системы обмена сообщениями в стиле Facebook
Считаете ли вы, что эта схема разметки выглядит нормально?
Учение schema.yml:
UserMessage:
tableName: user_message
actAs: [Timestampable]
columns:
id: { type: integer(10), primary: true, autoincrement: true }
sender_id : { type: integer(10), notnull: true }
sender_read: { type: boolean, default: 1 }
subject: { type: string(255), notnull: true }
message: { type: string(1000), notnull: true }
hash: { type: string(32), notnull: true }
relations:
UserMessageRecipient as Recipient:
type: many
local: id
foreign: message_id
UserMessageReply as Reply:
type: many
local: id
foreign: message_id
UserMessageReply:
tableName: user_message_reply
columns:
id: { type: integer(10), primary: true, autoincrement: true }
user_message_id as message_id: { type: integer(10), notnull: true }
message: { type: string(1000), notnull: true }
sender_id: { type: integer(10), notnull: true }
relations:
UserMessage as Message:
local: message_id
foreign: id
type: one
UserMessageRecipient:
tableName: user_message_recipient
actAs: [Timestampable]
columns:
id: { type: integer(10), primary: true, autoincrement: true }
user_message_id as message_id: { type: integer(10), notnull: true }
recipient_id: { type: integer(10), notnull: true }
recipient_read: { type: boolean, default: 0 }
Когда новый ответ сделал, я буду убеждаться логическое значение для «recipient_read» для каждого получателя устанавливается в ложь, и, конечно я уверен, что sender_read тоже установлен на false.
Я использую хэш для URL: http://example.com/user/messages/aadeb18f8bdaea49882ec4d2a8a3c062
(как идентификатор будет начиная с 1, я не хочу иметь http://example.com/user/messages/1 Да, я мог бы начать приращение от большего числа, но. я бы предпочел начать с 1.)
Это хороший способ обойти это? Ваши мысли и предложения были бы чрезвычайно оценены.
Спасибо, ребята!
UserMessage и UserMessageReply оба представляют один класс - сообщение. Я хотел бы создать один класс и связать его с самим собой полем reply_id. Читайте здесь о взаимоотношениях гнезд: http://www.doctrine-project.org/projects/orm/1.2/docs/manual/defining-models/zh#relationships:join-table-associations:self-referencing-nest-relations – Dziamid
Ах, интересно. Огромное спасибо. – Flukey
Вы с этим? Это было сделано в рельсах 3? – Angela