Parse.com - 查找已删除的对象 [英] Parse.com - Find deleted objects

查看:114
本文介绍了Parse.com - 查找已删除的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与Parse.com同步的iOS应用程序。

I have an iOS app that synchronises to Parse.com.

它可以找到添加到Parse的任何内容,并使用PFQuery将其添加到Core Data。它还可以检查已更新和相应更新的任何数据。

It can find anything that was added to Parse and add it to Core Data using PFQuery. It can also check for any data that has been updated and update accordingly.

但是,我不确定如何查找已在Parse.com上删除的对象。

However, I'm not sure how to find objects that have been deleted on Parse.com.

是否有人知道将列出已删除的ObjectID及其删除日期的查询?然后我可以从应用程序的核心数据中删除它们。

Does anyone know of a query that will list the ObjectIDs that have been deleted and the date of their deletion? I can then remove them from the Core Data on the app.

推荐答案

我也需要这个功能,但想到了标记行删除将使数据膨胀并为每个查询添加条件。所以我创建了一个Deletion类。它只记录任何已删除行的类名和ID,因此它保持很小:

I needed this function, too, but figured that marking rows as deleted will bloat the data and add a condition to every query. So I created a Deletion class. It records only the class name and ID of any deleted row, so it stays pretty small:

function recordDeletion(klass, identifier) {
    var Deletion = Parse.Object.extend("Deletion");
    var deletion = new Deletion();
    deletion.set("klass", klass);
    deletion.set("identifier", identifier);
    return deletion.save();
}

// for every class that you want deletions recorded, add one of these...
Parse.Cloud.beforeDelete("MyClass", function(request, response) {
    recordDeletion("MyClass", request.object.id).then(function() {response.success();});
});

我的iOS客户端记录上次提取数据的日期,然后从 MyClass (+其他)和删除。这样,就可以在本地删除删除。

My iOS clients record the date when they last fetched data, then get everything newly created/updated from MyClass (+ others) and Deletion. With that, the can delete the Deletions locally.

在更长的时间内,客户端会删除所有本地缓存​​的数据并获取所有内容的新副本(删除除外) 。这允许我在服务器上有一个预定的作业,它将清空Deletion表(在一个比客户端周期长得多的周期)。

Over a longer period, the clients remove all of the locally cached data and get a fresh copy of everything (except Deletions). This allows me to have a scheduled job on the server that will empty the Deletion table (on a cycle that's much longer than the client's cycle).

这篇关于Parse.com - 查找已删除的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆