ucharles / gachatory

https://www.gachatory.com
0 stars 0 forks source link

fix: Collection `capsule-toy`의 `updatedAt`에 문자열이 삽입됨 #113

Open ucharles opened 4 months ago

ucharles commented 4 months ago

상황

원인

해결

// node.js
[
  {
    '$match': {
      'updatedAt': new RegExp('-', 'i')
    }
  }, {
    '$addFields': {
      'updatedAt': {
        '$toDate': '$updatedAt'
      }
    }
  }
]
bulk_operation.append(
    UpdateOne(
        {"_id": capsule_info["_id"]},
        {
            "$push": {"tagId": tag_info["_id"]},
            "$set": {
                "updatedAt": datetime.utcnow()
            },  # datetime.utcnow().isoformat() -> datetime.utcnow() / isoformat()을 사용할 경우 string 형식으로 저장됨
        },
    )
)