> For the complete documentation index, see [llms.txt](https://docs.ohmyapp.io/main/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ohmyapp.io/main/guide/develop_app/command-execute-function/create-logic/flow_option/update-insert.md).

# If Data Exists, Modify / If Not, Create

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

<div align="left"><figure><img src="/files/atj5H9hLUwBCZPcMvgnZ" 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
