-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(dsl): Support create and upsert requests (#6)
Co-authored-by: Dragutin Marjanović <[email protected]> Co-authored-by: markaya <[email protected]>
- Loading branch information
Showing
4 changed files
with
55 additions
and
15 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
modules/library/src/main/scala/zio/elasticsearch/Document.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package zio.elasticsearch | ||
|
||
import zio.schema.Schema | ||
import zio.schema.codec.JsonCodec.JsonDecoder | ||
import zio.schema.codec.{DecodeError, JsonCodec} | ||
|
||
private[elasticsearch] final case class Document(json: String) { | ||
def decode[A](implicit schema: Schema[A]): Either[DecodeError, A] = JsonDecoder.decode(schema, json) | ||
} | ||
|
||
private[elasticsearch] object Document { | ||
def from[A](doc: A)(implicit schema: Schema[A]): Document = Document( | ||
JsonCodec.jsonEncoder(schema).encodeJson(doc, indent = None).toString | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
modules/library/src/main/scala/zio/elasticsearch/package.scala
This file was deleted.
Oops, something went wrong.