Skip to content

Commit

Permalink
Divide put to create and upsert
Browse files Browse the repository at this point in the history
  • Loading branch information
dbulaja98 committed Nov 28, 2022
1 parent e418675 commit a79c7e6
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,36 @@ object ElasticRequest {
case None => Left(DocumentNotFound)
}

def put[A: Schema](
def create[A: Schema](
index: IndexName,
id: Option[DocumentId],
doc: A,
routing: Option[Routing] = None
): ElasticRequest[Unit] =
Create(index, id, Document.from(doc), routing)

def upsert[A: Schema](
index: IndexName,
id: DocumentId,
doc: A,
routing: Option[Routing] = None
): ElasticRequest[Unit] =
Put(index, id, Document.from(doc), routing)
CreateOrUpdate(index, id, Document.from(doc), routing)

private[elasticsearch] final case class GetById(
index: IndexName,
id: DocumentId,
routing: Option[Routing] = None
) extends ElasticRequest[Option[Document]]

private[elasticsearch] final case class Put(
private[elasticsearch] final case class Create(
index: IndexName,
id: Option[DocumentId],
document: Document,
routing: Option[Routing] = None
) extends ElasticRequest[Unit]

private[elasticsearch] final case class CreateOrUpdate(
index: IndexName,
id: DocumentId,
document: Document,
Expand Down

0 comments on commit a79c7e6

Please sign in to comment.