Class: Workarea::GlobalE::OrderApiEvents

Inherits:
Object
  • Object
show all
Includes:
ApplicationDocument
Defined in:
app/models/workarea/global_e/order_api_events.rb

Class Method Summary collapse

Class Method Details

.upsert_one(id, set: {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/workarea/global_e/order_api_events.rb', line 15

def self.upsert_one(id, set: {})
  timestamp = Time.current

  collection.update_one(
    { _id: id.to_s },
    {
      '$setOnInsert' => { created_at: timestamp },
      '$set' => { updated_at: timestamp }.merge(set),
    },
    upsert: true
  )
end