{
_id: ObjectId(...),
discussion_id: ObjectId(...),
slug: '34db',
posted: ISODateTime(...),
author: {
id: ObjectId(...),
name: 'Rick'
},
text: 'This is so bogus ... '
}
这是我到目前为止所做的:
class Discussion
{
/**
* @MongoDB\Id
*/
protected $id;
/**
* @MongoDB\ObjectId
*/
protected $discussion_id;
/**
* @MongoDB\String
*/
protected $slug;
/**
* @MongoDB\String <---------- IS THIS THE RIGHT DATA TYPE?
*/
protected $author;
/**
* @MongoDB\String
*/
protected $text;
/**
* @MongoDB\Date
*/
protected $createdAt;
}
所以在我的代码中:
$author_info = array(
"userName" => $userName
);
$discussion = new Discussion();
$discussion->setCreatedAt(new \DateTime());
$discussion->setAuthor($author_info);
$discussion->setText($listingInquiry);
我的问题是我做得对吗?我有一种感觉,作者类型需要是别的东西。请建议。
谢谢