GithubHelp home page GithubHelp logo

Comments (12)

deanhiller avatar deanhiller commented on July 18, 2024

I am not sure at all what that function does? You say "That didn't load in any data" so you mean do not read from the database? and where is the key stored and this value, where am I supposed to check for those? Can you explain a bit more here?

from playorm.

nadenf avatar nadenf commented on July 18, 2024

So an example would be:

boolean emailExists = NoSql.em().contains(User.class, "emailAddress", "[email protected]")

And it would only check if the email exists not load any of the other attributes for the User class e.g. name, age etc.

from playorm.

deanhiller avatar deanhiller commented on July 18, 2024

There is no row key here though? If you are trying to answer the question is there a user with emailAddress=[email protected], would you mind if that was done like so..... select count(u) from User as u where u.emailAddress = '[email protected]' because I can add that AND it would only scan the index so it would not load the entire user object.

from playorm.

nadenf avatar nadenf commented on July 18, 2024

That looks great. Maybe instead of contains it could also be:

NoSql.em().count(User.class, "emailAddress", "[email protected]")

That way it could be generic and used in other situations. Either way is great.

from playorm.

deanhiller avatar deanhiller commented on July 18, 2024

hmmmm, I am rethinking this right now.....currently, we could just use the index and I believe you may be able to do this with today's api...it would only read in the primary key of the user itself. If you use TypedSession.runQuery("select t from User as t where t.emailAddress = '[email protected]') it does NOT run the query but returns and object that you iterate over.....well, actually returns 1 object and you can request one of 3 iterators. Anyways, I am wondering if we can put an abstraction on top of that to do what you want but in a general way for all users in different situations.

Vikas, I would love to hear your thoughts here as well???

from playorm.

easility avatar easility commented on July 18, 2024

Yes, I agree with Dean as we have added support to query on primary/row key as well, it makes sense to use the existing APIs and then see if it is returning anything.

Dean: Here, I am sure, you meant NoSqlTypedSession.createQueryCursor(sql,batchsize) as there is no API like runQuery..

~Vikas

from playorm.

deanhiller avatar deanhiller commented on July 18, 2024

yup, that would be the one......any ideas how you can get taligent something he can use in this regard?
thanks,
Dean

from playorm.

easility avatar easility commented on July 18, 2024

So, you will have to take latest code from master branch if you want to query on primary key(rowkey). Please note that you can still query on primary key or on an indexed column... you can do use any of the 3 iterator as Dean mentioned and do something like:

String sql = "select * from User where emailAddress = "[email protected]"";
QueryResult result = nosqlTypedSession.createQueryCursor(cmd, 100);

if (result.getAllViewsIter().iterator().hasNext())
//found it
OR

if (result.getAllViewsCursor().next())
//found it
OR
if (result.getPrimaryViewIter().iterator().hasNext())
//found it

from playorm.

deanhiller avatar deanhiller commented on July 18, 2024

thanks for adding that exact code. there is one better method that reads in no rows which is using that same result object above, call result.getCursor() which gives the index cursor so no rows are read and only the index is read. It returns the IndexColumnInfo. If anything exists you know your user exists all without reading the row. hmmmmm, any ideas on what to do with this issue from a more usable perspective or should we close it?

from playorm.

nadenf avatar nadenf commented on July 18, 2024

It would be nice to simplify it for the user as for most basic apps there is no need to access the cursor.

from playorm.

deanhiller avatar deanhiller commented on July 18, 2024

ok, I am trying to figure out if this belongs on the EntityManager(ie. JPA has no count method on the EntityManager) or maybe we just throw it on TypedSession so it is NoSql.em().getTypedSession().count(User.class, "emailAddress", "myemail");......in fact, I think that might be best. Are you good with that solution? If so, I think we will proceed once the play 2.x plugin is complete.

from playorm.

easility avatar easility commented on July 18, 2024

One method is added in NoSqlTypedSession
public int count(String columnFamily, String indexedColName, Object value)

I hope that will solve the purpose. I am closing this issue as of now. However, please re-open it if you face any issue in using that.

from playorm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.