パートナーからのオファーのコレクションを希望しているクライアントがいますが、変更を承認する必要があります。パートナーからの変更の履歴を保持する最良の方法は何ですか?
だからここにそれがどのように機能するかがあります
{
partner_id: {here}
offer1:
offer2:
offer3:
date:
status:
}
オファーが変更されたかどうかを確認する方法が必要です (ただし、1 つだけ戻る)。変更された場合は、挿入して過去のものを status:history として作成します。
次のステータスのみが存在する必要があります。
履歴
保留中
承認済み
しかし、彼らが新しいオファーを挿入しているが、承認済みのオファーがある場合は、承認されるまで承認されたままにする必要があります。
これどうやってするの?これが私が考えた方法です:
<?php
function checkoffers($data)
{
$this->data = $data;
$collection = $this->db->partner_offers;
if($this->data["_id"] != null)
{
$cursor = $collection->insert(RUN INSERT ARRAY)
}
else
{
$cursor = $collection->find(array("_id"=>new MongoId($this->data["_id"])));
if ($cursor->count() > 0)
{
$test = array();
while( $cursor->hasNext() ) {
$test[] = ($cursor->getNext());
}
foreach($test as $offers)
{
check to see if offer matches the past offer. if not then run new function and insert.
}
}
}
?>