小编Phi*_*lip的帖子

我正在尝试使用JMSSerizial Bundle序列化嵌入式mongodb文档

我试图在Symfony 2.1中序列化带有嵌入文档的MongoDB文档.我正在使用JMSserializer和Mongodb-odm包.

我有以下文件实体.

// Blog

namespace App\DocumentBundle\Document;

use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use JMS\SerializerBundle\Annotation\Type;

/**
 * @MongoDB\Document(repositoryClass="App\DocumentBundle\Repository\BlogRepository")
 */
class Blog {

    /**
     * @MongoDB\Id
     */
    protected $id;

    /**
     * @MongoDB\String
     * @Assert\NotBlank()
     */
    protected $title;

    /**
     * @MongoDB\string
     * @Assert\NotBlank()
     */
    protected $blog;

    /**
     * @MongoDB\EmbedMany(targetDocument="Tag")
     */
    private $tags;

    /**
     * @MongoDB\Timestamp
     */
    protected $created;

    /**
     * @MongoDB\Timestamp
     */
    protected $updated;
}
Run Code Online (Sandbox Code Playgroud)

// Tag

namespace App\DocumentBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

/**
 * @MongoDB\EmbeddedDocument
 */
class Tag …
Run Code Online (Sandbox Code Playgroud)

mongodb symfony jmsserializerbundle

7
推荐指数
1
解决办法
1314
查看次数

标签 统计

jmsserializerbundle ×1

mongodb ×1

symfony ×1