module.exports = function(obj, entryID, targetGroupID) { obj.groups = obj.groups || []; var location = searching.findGroupContainingEntryID(obj.groups, entryID), originGroup = location.group, originIndex = location.index; if (!originGroup) { throw new Error("Invalid entry ID"); } var targetGroup = searching.findGroupByID(obj.groups, targetGroupID); if (!targetGroup) { throw new Error("Invalid group ID"); } var movedEntry = originGroup.entries.splice(originIndex, 1)[0]; targetGroup.entries = targetGroup.entries || []; targetGroup.entries.push(movedEntry); };
module.exports = function(obj, groupID, title) { obj.groups = obj.groups || []; var group = searching.findGroupByID(obj.groups, groupID); if (!group) { throw new Error("Group not found for ID"); } group.title = title; };
module.exports = function(obj, groupID, attributeName, value) { obj.groups = obj.groups || []; var group = searching.findGroupByID(obj.groups, groupID); if (!group) { throw new Error("Group not found for ID"); } group.attributes = group.attributes || {}; group.attributes[attributeName] = value; };
module.exports = function(obj, entryID, attributeName, value) { obj.groups = obj.groups || []; var entry = searching.findEntryByID(obj.groups, entryID); if (!entry) { throw new Error("Entry not found for ID"); } entry.attributes = entry.attributes || {}; entry.attributes[attributeName] = value; };
module.exports = function(obj, entryID, propertyName, value) { obj.groups = obj.groups || []; var entry = Searching.findEntryByID(obj.groups, entryID); if (!entry) { throw new Error("Entry not found for ID"); } entry.meta = entry.meta || {}; entry.meta[propertyName] = value; };
module.exports = function(obj, entryID, propertyName, value) { obj.groups = obj.groups || []; if (!Entry.isValidProperty(propertyName)) { throw new Error("Invalid property name for entry: " + propertyName); } var entry = Searching.findEntryByID(obj.groups, entryID); if (!entry) { throw new Error("Entry not found for ID"); } entry[propertyName] = value; };
module.exports = function(obj, groupID, attributeName) { obj.groups = obj.groups || []; var group = searching.findGroupByID(obj.groups, groupID); if (!group) { throw new Error("Group not found for ID"); } group.attributes = group.attributes || {}; var deleted = delete group.attributes[attributeName]; if (!deleted) { throw new Error("Failed deleting attribute"); } };
module.exports = function(obj, entryID, attributeName) { obj.groups = obj.groups || []; var entry = searching.findEntryByID(obj.groups, entryID); if (!entry) { throw new Error("Entry not found for ID"); } entry.attributes = entry.attributes || {}; var deleted = delete entry.attributes[attributeName]; if (!deleted) { throw new Error("Failed deleting attribute"); } };