Symfony中Doctrine对应的Mongodb数据类型 data type

1. hash 就是 json对象

2. collection 就是 数组

3. 若要知道如何使用referenceOne, referenceMany, embbedDocument等

主要查看:

http://doctrine-mongodb-odm.readthedocs.org/en/latest/reference/reference-mapping.html

以上部分主要看yaml部分,就会知道如何编写 yml 了。
 
 
HasLifecycleCallbacks事件:
 
了解更多:
 
 
 
比较典型的yml:
 
DocumentsUser:
  fields:
    id:
      type: id
      id: true
    name:
      type: string
    email:
      type: string
  referenceMany:
    posts:
      targetDocument: DocumentsBlogPost
      cascade: all

DocumentsBlogPost:
  fields:
    id:
      type: id
      id: true
    title:
      type: string
    body:
      type: string
    createdAt:
      type: date
 
原文地址:https://www.cnblogs.com/vincedotnet/p/3583683.html