# If Data Exists, Modify / If Not, Create

조건에 맞는 데이터가 있으면 업데이트 하고, 조건에 맞는 데이터가 없으면 생성하는 동작을 수행해요.

<div align="left"><figure><img src="https://3976660509-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDgfvhQgmY9NbRK0Sln7j%2Fuploads%2F7IrZZ0MvOlxoPoM7soNu%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202024-01-09%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%206.18.31.png?alt=media&#x26;token=57bdeecb-d956-4a5f-94e2-79adac758561" alt="" width="375"><figcaption></figcaption></figure></div>

**Collection for Data Creation/Update** : 컬렉션 명

데이터를 저장할 컬렉션을 설정해요. 컬렉션 명은 대부분 메타ID와 같아요.

**Data Search Condition** : 데이터 검색 조건&#x20;

데이터를 등록/수정을 판단할 항목 값을 말해요.

날짜로 설정했다면 해당 날짜가 비어있으면 데이터가 추가, 다른 데이터가 있었으면 새 데이터로 수정돼요.

* 첫째 줄 Key 값에는 컬렉션에 정의된 값, 둘째 줄 Value값에는 가져올 데이터의 값을 적어요.
  * Key 값 : dateTime
  * Value값 : tmpDocument.dateTime

**Data Entries** : 업데이트할 값&#x20;

저장할 데이터를 정의해 주는 곳이에요. 주로 API 호출로 가져온 값을 저장할 곳을 지정해요.

* Key 값 : pm10Value
* Value값 : tmpDocument.pm10Value

**items** : 업데이트할 값에서 정의해 준 값을 실제 컬렉션의 항목 ID에 넣어주는 역할을 해요.

* 아래와 같이 작성해요.
* \[ { "pm10Value" : "tmpDocument.pm10Value", "pm25Value" : "tmpDocument.pm25Value" } ]

2024.01.09 Jinny

**Update and Insert**

This function involves updating data that meets specified conditions. In cases where no matching data exists, it performs the task of generating new data.

2023.08.11 Song
