With Scala Salat (using mongodb casbah), how to store and load binary data?

StackOverflow https://stackoverflow.com/questions/20114645

  •  03-08-2022
  •  | 
  •  

سؤال

I have a product case class defined in the way Salat expects.

case class Product(@Key("product_id") productId: String, 
                   @Key("png_image_binary") pngImageBinary: ???)

How can I add pngImageBinary so I can store this as a binary object?

هل كانت مفيدة؟

المحلول

For binary data you can use Array[Byte]. It's equivalent of java byte[], which maps to Binary BSON type. Check java types and BSON types from mongodb documentation.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top