def store(self, context): """Store the resource record into database table.""" values = { 'user_id': self.user_id, 'resource_type': self.resource_type, 'properties': self.properties, 'rule_id': self.rule_id, 'rate': self.rate, 'created_at': self.created_at, 'updated_at': self.updated_at, 'deleted_at': self.deleted_at, } if self.created_at: db_api.resource_update(context, self.id, values) else: values.id = values.update(id=self.id) resource = db_api.resource_create(context, values) self.created_at = resource.created_at return self.id