+1 especially for large tables

On Jan 22, 10:47 am, Locke <locke2...@gmail.com> wrote:
> It would be good to have the ability to do this from within the GUI.
> Other database management tools have "empty table" options, so a
> "delete all of this Kind" feature would be appropriate.
>
> On Jan 22, 12:59 pm, John Patterson <jdpatter...@gmail.com> wrote:
>
>
>
> > Here is the code I use to delete one kind at a time - it batches the  
> > keys into Lists of 100 to avoid datastore exceptions.  Iterables is  
> > from Google collections.
>
> >                                         Query query = new Query(kind);
> >                                         query.setKeysOnly();
> >                                         DatastoreService datastore = ...
> >                                         Iterable<Entity> entityIterator =  
> > datastore.prepare(query).asIterable();
> >                                         Iterable<Key> keyIterator = 
> > Iterables.transform(entityIterator,  
> > new Function<Entity, Key>()
> >                                         {
> >                                                 public Key apply(Entity 
> > arg0)
> >                                                 {
> >                                                         return 
> > arg0.getKey();
> >                                                 }
> >                                         });
>
> >                                         Iterable<List<Key>> partitioned =  
> > Iterables.partition(keyIterator, 100);
> >                                         for (List<Key> sublist : 
> > partitioned)
> >                                         {
> >                                                 datastore.delete(sublist);
> >                                         }
>
> > On 22 Jan 2010, at 15:10, mete wrote:
>
> > > Suppose I have a class A and I have stored some instance of it in the
> > > datastore. Then I change it, but I keep the name. How I can delete all
> > > the previous data in the datastore, if I simply do a query and use
> > > deleteAll, it gives an error (I guess because I changed the name of
> > > some fields). Thank you.
>
> > > Mete
>
> > > --
> > > You received this message because you are subscribed to the Google  
> > > Groups "Google App Engine for Java" group.
> > > To post to this group, send email to 
> > > google-appengine-java@googlegroups.com
> > > .
> > > To unsubscribe from this group, send email to 
> > > google-appengine-java+unsubscr...@googlegroups.com
> > > .
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/google-appengine-java?hl=en
> > > .- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to