Git Product home page Git Product logo

Comments (10)

mohsinraza avatar mohsinraza commented on July 18, 2024 7

I used the query builder for deleting with where clause

    public void deleteAllMessages() {
        RcMessagesDao messageDao = daoSession.getRcMessagesDao();  
        QueryBuilder qb = messageDao.queryBuilder();
        qb.where(ca.acesoft.reatchat.RcMessagesDao.Properties.Favorite.eq(false));
        List messageReceived = qb.list();
        messageDao.deleteInTx(messageReceived); 
    }

from greendao.

greenrobot-team avatar greenrobot-team commented on July 18, 2024 2

@jemshit If only that entity was affected that should work, it will clear the identity cache only for that entity. daoSesson.clear() does it for all entities. Just have a look at the (generated) code. -ut

from greendao.

greenrobot avatar greenrobot commented on July 18, 2024

Check out DeleteQuery: http://greendao-orm.com/javadoc/greendao/de/greenrobot/dao/DeleteQuery.html

I guess that's what you are looking for?

It's not documented fully yet, because its API is likely to change a bit in the future.

from greendao.

greenrobot avatar greenrobot commented on July 18, 2024

Sorry, a better pointer would have been to QueryBuilder.buildDelete(), which returns a DeleteQuery.

from greendao.

greenrobot avatar greenrobot commented on July 18, 2024

Actually, I decided to make this feature visible in the documentation (at the end of http://greendao-orm.com/documentation/queries/).

from greendao.

chrisjenx avatar chrisjenx commented on July 18, 2024

Ahh great, sorry should of looked a bit harder first!

Just need to make sure I refresh my models after deleting from what I can tell?

from greendao.

greenrobot avatar greenrobot commented on July 18, 2024

Bulk deletes are currently outside of the identity scope. It depends on your app structure if special treatment is required. For example, you could consider calling DaoSession.clear() to clear identity scope.

I'd close this issue for now.

from greendao.

Kozlov-V avatar Kozlov-V commented on July 18, 2024

@mohsinraza It is magic:
ca.acesoft.reatchat.RcMessagesDao.Properties.Favorite.eq(false) ?
what this? tell me please!
Thanks

from greendao.

jemshit avatar jemshit commented on July 18, 2024

Is it enough to call detachAll() on only daoObject that deleteQuery has been executed on? Instead of daoSesson.clear() ? @greenrobot

from greendao.

kpradeepkumarreddy avatar kpradeepkumarreddy commented on July 18, 2024

Can i use the following code to delete all rows from the table

DeleteQuery<Table> tableDeleteQuery = tableDao.queryBuilder().buildDelete();
tableDeleteQuery.executeDeleteWithoutDetachingEntities();

from greendao.

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.