code: def _upsert(context, params, data):
      
      table = params.get("table")
      table = datastore.get_table(table, primary_id=False)
      unique_keys = ensure_list(params.get("unique"))
      data["__last_seen"] = datetime.datetime.utcnow()
      if len(unique_keys):
          updated = table.update(data, unique_keys, return_count=True)
          if updated:
              return
      data["__first_seen"] = data["__last_seen"]
      table.insert(data)
docs: Insert or update data and add/update appropriate timestamps