Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping a Row object to a class or JSON response #18

Closed
ghost opened this issue Jan 14, 2019 · 11 comments
Closed

Mapping a Row object to a class or JSON response #18

ghost opened this issue Jan 14, 2019 · 11 comments
Labels
enhancement New feature or request
Milestone

Comments

@ghost
Copy link

ghost commented Jan 14, 2019

Hi there,

I'm sorry if I'm asking a stupid question but I was wondering what's the best way to retrieve the Cassandra data and map it to an object or JSON response?

With the Datastax driver it's recommended to use a mapper but i did not find a way to use the mapper here because the Cassandra session is closed off.

The other solution would be to create a customer handler that loops over the rows and transforms it to responses and/or POJO's.

Example code:

    database.executeWithFullFetch(query) { fetch ->
      if (fetch.succeeded()) {
        val rows = fetch.result()
        event.response().end() // best way to map it to a response?
      } else {
        println("Unable to execute the query")
        fetch.cause().printStackTrace()
      }
    }

I would appreciate the help.

@Sammers21
Copy link
Contributor

Sammers21 commented Jan 14, 2019

With the Datastax driver it's recommended to use a mapper but i did not find a way to use the mapper here because the Cassandra session is closed off.

Yes, for now, there is no way. But, even if we would expose the Session object you would be able to do save/get/delete operations in non-Vert.x way(with ListenableFuture), which is not good.

@Sammers21
Copy link
Contributor

As a solution, I think we can implement a wrapper around MappingManager and Mapper, so a user will be able to use result mapping and save/get/delete operations(which will return io.vertx.core.Future).

@Sammers21
Copy link
Contributor

@zwennesm, are you interested in contributing this?

@Sammers21 Sammers21 added the enhancement New feature or request label Jan 14, 2019
@ghost
Copy link
Author

ghost commented Jan 14, 2019

Sure thing, I’d be happy to help.

@Sammers21
Copy link
Contributor

Good. Look forward to your PR. If you have any questions, feel free to ask them.

@tsegismont
Copy link
Contributor

@Sammers21 @zwennesm implementing a vertxy mapping manager sounds good to me. However it shouldn't be done with Future, but rather with a Handler<AsyncResult>. Then codegen will be able to process the methods and generate the rxified API.

@Sammers21
Copy link
Contributor

However it shouldn't be done with Future, but rather with a Handler.

agree with this

@ghost
Copy link
Author

ghost commented Jan 15, 2019

Thanks @Sammers21 and @tsegismont for the instructions and information. I'll give it a start somewhere in the upcoming days. One small question upfront though. Would you like the mapper to be integrated into the vertx-cassandra-client, or shall I make it as a separate dependency so that users can decide whether to include it or not (such as this: https://github.com/ef-labs/vertx-cassandra).

@tsegismont
Copy link
Contributor

tsegismont commented Jan 15, 2019 via email

@Sammers21
Copy link
Contributor

I believe having a single project is better.

+1

@ghost ghost mentioned this issue Jan 21, 2019
@tsegismont tsegismont added this to the 3.7.0 milestone Jan 23, 2019
@tsegismont
Copy link
Contributor

Fixed in #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants