Implements object.messages.

This commit is contained in:
Julien Fontanet 2015-05-28 15:36:27 +02:00
parent 2653ff6536
commit 0b01a79d9d

View File

@ -82,10 +82,18 @@ function defineDeprecatedUUID (object) {
// }
function setMultiple (collection, items) {
var messages = collection.indexes.messagesByObject
forEach(items, function (item, key) {
defineDeprecatedUUID(item)
// createAutoLinks(collection, item)
defineProperty(item, 'messages', {
get: function () {
return messages[key]
}
})
collection.set(key, item)
})
}
@ -142,6 +150,11 @@ function Xo (opts) {
var objects = this.objects = new Collection()
objects.createIndex('ref', new UniqueIndex('ref'))
objects.createIndex('type', new Index('type'))
objects.createIndex('messagesByObject', new Index(function (obj) {
if (obj.type === 'message') {
return obj.$object
}
}))
this.status = 'disconnected'
this.user = null