List changed fields of model
 @param document [Mongoid::Document]
 @return [String] field, embedded{field}
489409
def document_changes(document)
      (document.changed + document._children.select{|child| child.changed? }.map { |child|
        "#{child.metadata_name.to_s}{#{child.changed.join(", ")}}"
      }).join(", ")
    end
1349301
def get_document_list(self):
        
        try:
            return self.__dict__['document_list']
        except KeyError:
            obj_list = DocumentSet([
                self._connection.documents.get(i) for i in self.document_ids
            ])
            self.__dict__['document_list'] = obj_list
            return obj_list
1259109
def track_external_change(app_id, action, document)
      return unless Conf.redis
      Conf.redis.rpush("#{KEYS[:changes]}-#{app_id}", MultiJson.encode([action, document]))
    end
239044
def delete(self, **kwargs):
        
        if self.is_valid:
            if '_id' in self._document:
                to_delete = self.find_one({'_id': self._id})

                if to_delete:
                    before = self.before_delete()
                    if before:
                        return before

                    try:
                        self.delete_one({'_id': self._id})

                        self.after_delete()

                        return self._document
                    except PyMongoException as exc:
                        return PyMongoError(
                            error_message=exc.details.get(
                                'errmsg', exc.details.get(
                                    'err', 'PyMongoError.'
                                )
                            ),
                            operation='delete', collection=type(self).__name__,
                            document=self._document,
                        )
                else:
                    return DocumentNotFoundError(type(self).__name__, self._id)
            else:
                return UnidentifiedDocumentError(
                    type(self).__name__, self._document
                )
1106781
def from_model(cls, document):
        
        return cls(meta={'id': document.id}, **cls.serialize(document))
539025
def content_fields
      output = {}

      # Include file content-related fields
      if is_a?(Jekyll::StaticFile)
        output["encoded_content"] = encoded_content
      elsif is_a?(JekyllAdmin::DataFile)
        output["content"] = content
        output["raw_content"] = raw_content
      else
        output["raw_content"] = raw_content
        output["front_matter"] = front_matter
      end

      # Include next and previous documents non-recursively
      if is_a?(Jekyll::Document)
        %w(next previous).each do |direction|
          method = "#{direction}_doc".to_sym
          doc = public_send(method)
          output[direction] = doc.to_api if doc
        end
      end

      output
    end
1202050
def document(self):
        
        doc = {'mode': self.__mongos_mode}
        if self.__tag_sets not in (None, [{}]):
            doc['tags'] = self.__tag_sets
        if self.__max_staleness != -1:
            doc['maxStalenessSeconds'] = self.__max_staleness
        return doc
1034095
public function prepareUpdateData($document)
    {
        $class     = $this->dm->getClassMetadata(get_class($document));
        $changeset = $this->uow->getDocumentChangeSet($document);

        $updateData = [];
        foreach ($changeset as $fieldName => $change) {
            $mapping = $class->fieldMappings[$fieldName];

            // skip non embedded document identifiers
            if (! $class->isEmbeddedDocument && ! empty($mapping['id'])) {
                continue;
            }

            [$old, $new] = $change;

            // Scalar fields
            if (! isset($mapping['association'])) {
                if ($new === null && $mapping['nullable'] !== true) {
                    $updateData['$unset'][$mapping['name']] = true;
                } else {
                    if ($new !== null && isset($mapping['strategy']) && $mapping['strategy'] === ClassMetadata::STORAGE_STRATEGY_INCREMENT) {
                        $operator = '$inc';
                        $value    = Type::getType($mapping['type'])->convertToDatabaseValue($new - $old);
                    } else {
                        $operator = '$set';
                        $value    = $new === null ? null : Type::getType($mapping['type'])->convertToDatabaseValue($new);
                    }

                    $updateData[$operator][$mapping['name']] = $value;
                }

            // @EmbedOne
            } elseif (isset($mapping['association']) && $mapping['association'] === ClassMetadata::EMBED_ONE) {
                // If we have a new embedded document then lets set the whole thing
                if ($new && $this->uow->isScheduledForInsert($new)) {
                    $updateData['$set'][$mapping['name']] = $this->prepareEmbeddedDocumentValue($mapping, $new);

                // If we don't have a new value then lets unset the embedded document
                } elseif (! $new) {
                    $updateData['$unset'][$mapping['name']] = true;

                // Update existing embedded document
                } else {
                    $update = $this->prepareUpdateData($new);
                    foreach ($update as $cmd => $values) {
                        foreach ($values as $key => $value) {
                            $updateData[$cmd][$mapping['name'] . '.' . $key] = $value;
                        }
                    }
                }

            // @ReferenceMany, @EmbedMany
            } elseif (isset($mapping['association']) && $mapping['type'] === 'many' && $new) {
                if (CollectionHelper::isAtomic($mapping['strategy']) && $this->uow->isCollectionScheduledForUpdate($new)) {
                    $updateData['$set'][$mapping['name']] = $this->prepareAssociatedCollectionValue($new, true);
                } elseif (CollectionHelper::isAtomic($mapping['strategy']) && $this->uow->isCollectionScheduledForDeletion($new)) {
                    $updateData['$unset'][$mapping['name']] = true;
                    $this->uow->unscheduleCollectionDeletion($new);
                } elseif (CollectionHelper::isAtomic($mapping['strategy']) && $this->uow->isCollectionScheduledForDeletion($old)) {
                    $updateData['$unset'][$mapping['name']] = true;
                    $this->uow->unscheduleCollectionDeletion($old);
                } elseif ($mapping['association'] === ClassMetadata::EMBED_MANY) {
                    foreach ($new as $key => $embeddedDoc) {
                        if ($this->uow->isScheduledForInsert($embeddedDoc)) {
                            continue;
                        }

                        $update = $this->prepareUpdateData($embeddedDoc);
                        foreach ($update as $cmd => $values) {
                            foreach ($values as $name => $value) {
                                $updateData[$cmd][$mapping['name'] . '.' . $key . '.' . $name] = $value;
                            }
                        }
                    }
                }

            // @ReferenceOne
            } elseif (isset($mapping['association']) && $mapping['association'] === ClassMetadata::REFERENCE_ONE) {
                if (isset($new) || $mapping['nullable'] === true) {
                    $updateData['$set'][$mapping['name']] = $new === null ? null : $this->prepareReferencedDocumentValue($mapping, $new);
                } else {
                    $updateData['$unset'][$mapping['name']] = true;
                }
            }
        }
        // collections that aren't dirty but could be subject to update are
        // excluded from change set, let's go through them now
        foreach ($this->uow->getScheduledCollections($document) as $coll) {
            $mapping = $coll->getMapping();
            if (CollectionHelper::isAtomic($mapping['strategy']) && $this->uow->isCollectionScheduledForUpdate($coll)) {
                $updateData['$set'][$mapping['name']] = $this->prepareAssociatedCollectionValue($coll, true);
            } elseif (CollectionHelper::isAtomic($mapping['strategy']) && $this->uow->isCollectionScheduledForDeletion($coll)) {
                $updateData['$unset'][$mapping['name']] = true;
                $this->uow->unscheduleCollectionDeletion($coll);
            }
            // @ReferenceMany is handled by CollectionPersister
        }
        return $updateData;
    }
978848
def get_field_embedded_doc(node):
    """"""

    definition = get_field_definition(node)
    cls_name = definition.last_child().last_child()
    cls = next(cls_name.infer())
    return cls
571508
private function computeChildrenChanges($document, $class, $oid, $isNew, $changeSet)
    {
        $id = $this->getDocumentId($document, false);

        foreach ($class->childrenMappings as $fieldName) {
            if ($changeSet[$fieldName] instanceof PersistentCollection) {
                if (!$changeSet[$fieldName]->isInitialized()) {
                    continue;
                }
            } else {
                if (null === $changeSet[$fieldName]) {
                    $changeSet[$fieldName] = [];
                }

                if (!is_array($changeSet[$fieldName]) && !$changeSet[$fieldName] instanceof Collection) {
                    throw PHPCRException::childrenFieldNoArray(
                        self::objToStr($document, $this->dm),
                        $fieldName
                    );
                }

                $filter = $mapping['filter'] ?? null;
                $fetchDepth = $mapping['fetchDepth'] ?? null;

                // convert to a PersistentCollection
                $changeSet[$fieldName] = ChildrenCollection::createFromCollection(
                    $this->dm,
                    $document,
                    $changeSet[$fieldName],
                    $filter,
                    $fetchDepth,
                    !$isNew
                );

                $class->setFieldValue($document, $fieldName, $changeSet[$fieldName]);
                $this->originalData[$oid][$fieldName] = $changeSet[$fieldName];
            }

            $mapping = $class->mappings[$fieldName];
            $childNames = $movedChildNames = [];

            $coid = spl_object_hash($changeSet[$fieldName]);
            $this->visitedCollections[$coid] = $changeSet[$fieldName];

            foreach ($changeSet[$fieldName] as $originalNodename => $child) {
                if (!is_object($child)) {
                    throw PHPCRException::childrenContainsNonObject(
                        self::objToStr($document, $this->dm),
                        $fieldName,
                        gettype($child)
                    );
                }

                $nodename = $this->getChildNodename($id, $originalNodename, $child, $document);
                $changeSet[$fieldName][$nodename] = $this->computeChildChanges($mapping, $child, $id, $nodename, $document);
                if (0 !== strcmp($originalNodename, $nodename)) {
                    unset($changeSet[$fieldName][$originalNodename]);
                    $movedChildNames[] = (string) $originalNodename;
                }
                $childNames[] = $nodename;
            }

            if ($isNew) {
                continue;
            }

            if (!$this->originalData[$oid][$fieldName] instanceof ChildrenCollection) {
                throw new RuntimeException('OriginalData for a children association contains something else than a ChildrenCollection.');
            }

            $this->originalData[$oid][$fieldName]->initialize();
            $originalNames = $this->originalData[$oid][$fieldName]->getOriginalNodenames();
            foreach ($originalNames as $key => $childName) {
                // check moved children to not accidentally remove a child that simply moved away.
                if (!(in_array($childName, $childNames) || in_array($childName, $movedChildNames))) {
                    $child = $this->getDocumentById($id.'/'.$childName);
                    $this->scheduleRemove($child);
                    unset($originalNames[$key]);
                }
            }

            if (!empty($childNames) && isset($originalNames)) {
                // reindex the arrays to avoid holes in the indexes
                $originalNames = array_values($originalNames);
                $originalNames = array_merge($originalNames, array_diff($childNames, $originalNames));
                if ($originalNames != $childNames) {
                    $reordering = NodeHelper::calculateOrderBefore($originalNames, $childNames);
                    if (empty($this->documentChangesets[$oid])) {
                        $this->documentChangesets[$oid] = ['reorderings' => [$reordering]];
                    } else {
                        $this->documentChangesets[$oid]['reorderings'][] = $reordering;
                    }

                    $this->scheduledUpdates[$oid] = $document;
                } elseif (empty($this->documentChangesets[$oid]['fields'])) {
                    unset($this->documentChangesets[$oid], $this->scheduledUpdates[$oid]);
                } else {
                    $this->documentChangesets[$oid]['reorderings'] = [];
                }
            }
        }
    }
377775
def get_document_field_display(self, field_name, field):
        
        document = getattr(self.instance, field_name)
        if document:
            return mark_safe(
                '<a href="%s">%s <span class="meta">(%s, %s)</span></a>' % (
                    document.url,
                    document.title,
                    document.file_extension.upper(),
                    filesizeformat(document.file.size),
                )
            )
        return self.model_admin.get_empty_value_display()
1021310
def document_overrides(document)
      if document.respond_to?(:data) and document.data.has_key?("app_engine")
        document.data.fetch("app_engine")
      else
        {}
      end
    end
276904
def on_change(on_change_method, field_name, field_value, *args)
      # NOTE: OpenERP doesn't accept context systematically in on_change events unfortunately
      ids = self.id ? [id] : []
      result = self.class.object_service(:execute, self.class.openerp_model, on_change_method, ids, *args)
      load_on_change_result(result, field_name, field_value)
    end
811562
def related_items_changed(self, instance, related_manager):
        
        assigned = related_manager.select_related("keyword")
        keywords = " ".join([str(a.keyword) for a in assigned])
        string_field_name = list(self.fields.keys())[0] % \
                            self.related_field_name
        if getattr(instance, string_field_name) != keywords:
            setattr(instance, string_field_name, keywords)
            instance.save()
72270
def find_breaking_changes(
    old_schema: GraphQLSchema, new_schema: GraphQLSchema
) -> List[BreakingChange]:
    
    return (
        find_removed_types(old_schema, new_schema)
        + find_types_that_changed_kind(old_schema, new_schema)
        + find_fields_that_changed_type_on_object_or_interface_types(
            old_schema, new_schema
        )
        + find_fields_that_changed_type_on_input_object_types(
            old_schema, new_schema
        ).breaking_changes
        + find_types_removed_from_unions(old_schema, new_schema)
        + find_values_removed_from_enums(old_schema, new_schema)
        + find_arg_changes(old_schema, new_schema).breaking_changes
        + find_interfaces_removed_from_object_types(old_schema, new_schema)
        + find_removed_directives(old_schema, new_schema)
        + find_removed_directive_args(old_schema, new_schema)
        + find_added_non_null_directive_args(old_schema, new_schema)
        + find_removed_directive_locations(old_schema, new_schema)
    )
306455
def __list_fields(cls):
        
        for name in cls._doc_type.mapping:
            field = cls._doc_type.mapping[name]
            yield name, field, False

        if hasattr(cls.__class__, '_index'):
            if not cls._index._mapping:
                return
            for name in cls._index._mapping:
                # don't return fields that are in _doc_type
                if name in cls._doc_type.mapping:
                    continue
                field = cls._index._mapping[name]
                yield name, field, True
353528
def get_fields(self):
        
        result = [key for key in self.__original_data__.keys()
                  if key not in self.__deleted_fields__]
        result.extend([key for key in self.__modified_data__.keys()
                       if key not in result and key not in self.__deleted_fields__])

        return result