Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 22 00:46
    darkfrog26 opened #99
  • May 22 00:46

    darkfrog26 on cats-effect-3.3.12

    Update cats-effect to 3.3.12 (compare)

  • May 22 00:46
    darkfrog26 opened #98
  • May 22 00:45

    darkfrog26 on jackson-dataformat-velocypack-3.0.1

    Update jackson-dataformat-veloc… (compare)

  • May 22 00:45
    darkfrog26 opened #97
  • May 22 00:45

    darkfrog26 on arangodb-java-driver-6.17.0

    Update arangodb-java-driver to … (compare)

  • May 01 00:55
    darkfrog26 opened #96
  • May 01 00:55

    darkfrog26 on scalatest-3.2.12

    Update scalatest to 3.2.12 (compare)

  • Apr 15 02:23
    darkfrog26 commented #94
  • Apr 15 02:22
    darkfrog26 closed #94
  • Apr 15 02:22

    darkfrog26 on master

    Removed scribe-slf4j dependency… (compare)

  • Apr 15 02:21

    darkfrog26 on master

    Update scala3-library, ... to 3… Merge pull request #95 from out… (compare)

  • Apr 15 02:21

    darkfrog26 on scala3-library-3.1.2

    (compare)

  • Apr 15 02:21
    darkfrog26 closed #95
  • Apr 15 02:20
    darkfrog26 opened #95
  • Apr 15 02:19

    darkfrog26 on scala3-library-3.1.2

    Update scala3-library, ... to 3… (compare)

  • Apr 15 02:18

    darkfrog26 on master

    Update fs2-core to 3.2.7 Merge branch 'master' into upda… Merge pull request #90 from out… (compare)

  • Apr 15 02:18

    darkfrog26 on fs2-core-3.2.7

    (compare)

  • Apr 15 02:18
    darkfrog26 closed #90
  • Apr 15 02:18
    darkfrog26 synchronize #90
elyphas
@elyphas

I am trying to make this function generic:

    def updateStockReturnNew(item: String, output: Int, movementStock: MovementStock): Future[Either[String, (Articulo, EventsDBResult)]] = {
          val updateAmount = if (movementStock == DecrementStock) (output * -1) else output
          val query = aqlu"""
                        FOR a IN tblartic FILTER a.cve_articulo == $item
                          UPDATE a WITH { stock: a.stock + $updateAmount }
                          IN tblartic
                          LET new = NEW
                          RETURN new
                      """
      /*val i = ItemRecipeScarango.ref
      val query = aql {
                      FOR (i) IN database.detailsRecipe
                      FILTER ( (i.type_document === item.type_document) && (i.fiscal_period === item.fiscal_period) && (i.folio === item.folio) )
                      RETURN (i)
                  }*/

but I think I need a type class

I think I need to make some changes on the code like:

case class ArticuloScarango (
        ...
        partida_descripcion: Option[String] = None,
        stock: Int,
        _id: Id[ArticuloScarango] = //ArticuloScarango.id()      //comment for the change
) extends Document[ArticuloScarango]

//change object for a class
object ArticuloScarangoModel extends DocumentModel[ArticuloScarango] {

     ...    
      def ref: DocumentRef[ArticuloScarango, ArticuloScarangoModel] = DocumentRef(this, Some("a"))

      ....
}

And in my type class do something like this:

trait RecordScarango[ScarangoType <: Document[ScarangoType], NativeType, Model <: DocumentModel[ScarangoType]]{
          ....
          def ref: DocumentRef[ScarangoType, Model]
}

and in my implementation:

   implicit val articuloScarango = new RecordScarango[ArticuloScarango, Articulo, ArticuloScarangoModel] {
                  val articulo = new ArticuloScarangoModel
                  def ref: DocumentRef[ArticuloScarango, ArticuloScarangoModel] = DocumentRef(articulo, Some("a"))

What do You think ?

elyphas
@elyphas
what I am afraid of is a wrong behavior because I need to change more code aside from this.
Matt Hicks
@darkfrog26
Just out of curiosity, why the DSL instead of just using the interpolator?
Unfortunately, the DSL is still a bit lacking and can't represent all situations.
elyphas
@elyphas
oh because I just start to understand how to use typeclass and I wanted to make the right way but seems in this case use the interpolator is the better way. :-)
Matt Hicks
@darkfrog26
Feel free to contribute a PR if you feel up to improving the DSL
the primary purpose of the DSL is for more complex scenarios where you have conditional paths to building complex queries
Sadly, because of the complexity, I only added the basics + the features I needed for the project I was working on
elyphas
@elyphas
ok :-)
@darkfrog26 ; by the way this kind of pattern:
D <: Document[D]
is just a recursive type?

Feel free to contribute a PR if you feel up to improving the DSL

I hope very soon I will do it, :-)

Matt Hicks
@darkfrog26
self-referencing type
elyphas
@elyphas
thank you
Matt Hicks
@darkfrog26
If you all haven't been following the GitHub project, Scarango 3.1 is out now.
elyphas
@elyphas
Thank you very much
Luis Furnas
@luisfurnas-pma
@darkfrog26 can I contribute with more features for the DSL?
Matt Hicks
@darkfrog26
@luisfurnas-pma definitely! Feel free to create a PR if you have any worthwhile additions.
The DSL is certainly not complete and I tend to add to it when I run into specific features that I need.
Luis Furnas
@luisfurnas-pma
thanks, I'll do that. I'm using now ArangoDB extensively so I'll kinda need to add a lot of features
Matt Hicks
@darkfrog26
With any PR just make sure to update the DSLSpec to validate the output is correct
Luis Furnas
@luisfurnas-pma
will do :)
shall I create issues in the repo to explain the features?
Matt Hicks
@darkfrog26
Sure, that's fine by me
Matt Hicks
@darkfrog26
Scarango 3.4.0 is now released: https://github.com/outr/scarango/releases/tag/3.4.0
elyphas
@elyphas
@darkfrog26 ; thank you very much ! :-)
Matt Hicks
@darkfrog26
elyphas
@elyphas
@darkfrog26 ; thank you ! :-)
Matt Hicks
@darkfrog26
Lots better type-safety, but it may break some things
elyphas
@elyphas
well, I think is worth :-)
elyphas
@elyphas

@darkfrog26 ; I have query saved in arangodb, and this query I want to be used as collection.
How can I do that

eg: "FOR doc IN tblrecipe RETURN doc"

This is saved on arangodb as "qry_recipe" and I wanted to used as collection like this:

database.tblartic.query("FOR doc1 IN qry_recipe RETURN doc1").cursor

is there some prefix to be use to run it?

Matt Hicks
@darkfrog26
@elyphas I'm not sure I understand...you mean a query stored in the web interface?
elyphas
@elyphas
yes
but seems it is not possible
Matt Hicks
@darkfrog26
I think that's just a convenience feature of the web interface, not something exposed outside
elyphas
@elyphas
ah
Matt Hicks
@darkfrog26
I've been thinking about writing a type-safe query file feature to generate code that would offer something like this, I just haven't gotten around to it
elyphas
@elyphas
@darkfrog26 , thank you !
Matt Hicks
@darkfrog26
what is the problem you are trying to solve? Just avoiding injecting the large query into your code?
elyphas
@elyphas

I've been thinking about writing a type-safe query file feature to generate code that would offer something like this, I just haven't gotten around to it

that would be cool :-)

what is the problem you are trying to solve? Just avoiding injecting the large query into your code?

yes the second question

only that
Matt Hicks
@darkfrog26
you could load the query from a file?
elyphas
@elyphas
not a problem per se

you could load the query from a file?

I will try it

@darkfrog26 , thank you !!
Matt Hicks
@darkfrog26
I do that sometimes for very large queries to avoid the code smell
elyphas
@elyphas
seems very good idea
Matt Hicks
@darkfrog26
no problem...good luck and if you think of something that would make this better that could be added to Scarango let me know!
elyphas
@elyphas
ok I will do