Пример #1
0
 /**
  * Save the document
  * 
  * @param Entity $document
  */
 public static function save(Entity $document)
 {
     if ($document instanceof Entity\LazyLoading && $document->isGhost()) {
         throw new \Exception("Unable to save: This " . get_class($document) . " entity isn't fully loaded. " . "First expand, than edit, than save.");
     }
     static::getCollection()->save($document);
 }
Пример #2
0
 /**
  * Convert child to an id
  * 
  * @param Entity $item
  * @return \MongoId|mixed
  */
 protected static function childEntityToId(Entity $item)
 {
     if ($item instanceof Meta\Introspection && is_scalar($item::getIdProperty()) && $item::meta()->ofProperty($item::getIdProperty())['dbFieldType'] === '\\MongoId') {
         $id = new \MongoId($item->getId());
     } else {
         $id = $item->getId();
     }
     return $id;
 }