为什么Eclipse需要传入的网络连接(使用OS X)?(Why does Eclipse want incoming network connections (using OS X)?)
有谁知道为什么Eclipse要求传入网络连接? 我四处搜索并看到PyDev提到代码完成,但是我在PyDev中禁用了代码完成,重新启动,仍然提示输入网络连接。
Does anyone know why Eclipse is asking for incoming network connections? I searched around and saw mentions of Code Completion with PyDev, but I disabled code completion in PyDev, restarted, and was still prompted for incoming network connections.
原文:https://stackoverflow.com/questions/28516843
最满意答案
Realm支持称为主键的东西,它看起来非常适合您的问题。
主键是Realm对象的唯一标识符; 它可以是整数或字符串。 在您的情况下,您可以使用URL作为主键(如果每个餐厅确实只与一个URL关联),或者添加新属性作为主键(可能是
name
字段)。然后,您可以使用
addOrUpdateObject:
方法而不是addObject:
方法。 此方法仅适用于具有主键的对象类型。在您的情况下,假设您为
Restaurant
模型类型设置了主键,Realm将执行以下操作之一:
- 如果
Restaurant
之前已添加到Realm并且相对于您的新模型没有更改,则不会发生任何变化。- 如果
Restaurant
之前已添加到Realm但您的模型已更改,则Realm中的现有模型将更新。- 如果以前没有将
Restaurant
添加到Realm,则会添加它。希望有所帮助。
Realm supports something called primary keys, which seem like a good fit for your problem.
A primary key is a unique identifier for an Realm object; it can be an integer or a string. In your case, you might use the URL as the primary key (if each restaurant is indeed associated with only one URL), or add a new property to serve as the primary key (perhaps a
name
field).You can then use the
addOrUpdateObject:
method instead of theaddObject:
method. This method only works for object types with primary keys.In your case, assuming you set up a primary key for your
Restaurant
model type, Realm would do one of the following:
- If the
Restaurant
was previously added to the Realm and has not changed relative to your new model, nothing will change.- If the
Restaurant
was previously added to the Realm but your model has since changed, the existing model in the Realm will be updated.- If the
Restaurant
wasn't previously added to the Realm, it will be added.Hope that helps.
相关问答
更多-
更新Realm中的对象(Updating an object in Realm)[2022-11-16]
以下是有关更新Realm中的对象的文档 。 这里是另一个更新对象的选项,而不是其他答案中讨论的对象。 很多时候,当我想更新对象时,我只需要更新一个或两个属性,一个关于Realm的令人烦恼的事情是持久化对象的属性更改需要包装在写入事务中,所以我通常添加一个包装器方法来我的对象清理接口了一下: @implementation SomeRealmClass - (void)update:(void (^)(SomeRealmClass *instance))updateBlock { ... -
Realm支持称为主键的东西,它看起来非常适合您的问题。 主键是Realm对象的唯一标识符; 它可以是整数或字符串。 在您的情况下,您可以使用URL作为主键(如果每个餐厅确实只与一个URL关联),或者添加新属性作为主键(可能是name字段)。 然后,您可以使用addOrUpdateObject:方法而不是addObject:方法。 此方法仅适用于具有主键的对象类型。 在您的情况下,假设您为Restaurant模型类型设置了主键,Realm将执行以下操作之一: 如果Restaurant之前已添加到Realm并 ...
-
所以最简单的方法是进行查询并检查返回的Object是否为null: ObjectsInGroupRealm object = realm.where(ObjectsInGroupRealm.class) .equalTo("name", name) .equalTo("groupName", groupName) .findFirst(); if(object == null){ //add new object } else { //handle objec ...
-
这应该工作: RealmConfiguration config = getConfig(); if (new File(config.getPath()).exists()) { // exists } else { // don't exists } This should work: RealmConfiguration config = getConfig(); if (new File(config.getPath()).exists()) { // exists } else { ...
-
Realm.create是否会用相同的主键更新对象?(Realm.create will it update the object with the same primary key?)[2021-08-23]
是的,在调用Realm.create(_:value:update:)时指定update: true将导致正在更新的现有对象。 以下是基于您提供的代码演示的代码段: class Book: Object { dynamic var id = "" dynamic var title = "" dynamic var price = 0.0 override class func primaryKey() -> String? { return "id" } } let ... -
我有点困惑......你的问题到底是什么。 我选择你的最后一行 有什么方法可以在没有查询的情况下返回对象吗? 在某个领域中,您必须假设其他客户端修改您的数据,因此查询是强制性的 I am a bit confused... what exactly is your question. I pick your final line is there any way to return the object without a query? No. in a realm, you always have to ...
-
我如何在Realm Java中实现同样的功能? 没有在文档中找到此功能。 这有两种方法, 1.) copyToRealmOrUpdate()返回托管代理 2.) insertOrUpdate()不返回托管代理(所以插入多个项目时速度更快) How can I achieve the same in Realm Java? Didn't find this function in the docs. There are two methods for this, 1.) copyToRealmOrUpdate ...
-
检查领域对象是否已删除(Check if realm object is deleted)[2022-01-01]
如果已从包含的isInvalidated删除对象,或者在包含的isInvalidated上调用isInvalidated则无法再访问对象。 这是Object.isInvalidated 的文档 。 添加override var isInvalidated: Bool { return super.isInvalidated }到您的Object An object can no longer be accessed if the object has been deleted from the contai ... -
Realm找不到现有项目(Realm doesn't find existing items)[2022-06-18]
你的逻辑实际上有些错误。 通过在事务外部执行查询,后台同步线程可以在您执行查询和开始事务之间将数据放入Realm。 事务将始终将Realm移动到最新版本,因此也不需要调用refresh() 。 你的逻辑应该是这样的: realm.beginTransaction(); ourInstance = realm.where(PlannerManager.class).findFirst(); if (ourInstance == null) { ourInstance = r ... -
您将在循环的两个分支中返回,它会立即退出函数。 你不想在第一次失败时返回false,但是只有在失败之后才会返回false(我认为)。 You are returning in both branches of the loop, which immediately exits out of the function. You do not want to return false on the first failure, but only after all have failed (I think).