realm

Select a Random row in realm table

ⅰ亾dé卋堺 提交于 2019-12-23 16:08:22
问题 I want to select a random row from the realm table. Something like - SELECT * FROM table ORDER BY RANDOM() LIMIT 1; 回答1: Something like this would do, yes? Random random = new Random(); RealmResults<YourTable> list = realm.where(YourTable.class).findAll(); YourTable yourTable = list.get(random.nextInt(list.size())); 回答2: Depends on what you want to do: Do you want to get a random row from a table? Or A (random) row from a random table? I guess you mean the former: If you have an id in your

Printing a Realm Query

孤者浪人 提交于 2019-12-23 12:46:28
问题 I am migrating my existing project's database from SQLite to Realm. So there is a way to print Query like we can get/print in SQLite. SQL Query: select * from Patient where "revision=8" and (long_description like="%bone%" or code like="%bone%") order by code My Realm Query: realm.where(Patient.class) .equalTo("revision", "8") .and() .beginGroup() .like("long_description", "*bone*").or() .like("code", "*bone*") .endGroup() .sort("code"); 来源: https://stackoverflow.com/questions/49936344

Realm migration not called

℡╲_俬逩灬. 提交于 2019-12-23 10:10:52
问题 I've added a value to a realm object (I've added dynamic var inspectorName = "" to the WeekReport object), and I'm trying to migrate the realm database to contain that value. I'm trying to call the migration block in func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) like this: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)

Regarding Header 'RealmSwift-Swift.h' not found error

可紊 提交于 2019-12-23 09:50:06
问题 I've updated my Xcode to the Xcode 10.0 beta version and tried to run a project with realmswift in it, now i'm facing an error where it says: Header 'RealmSwift-Swift.h' not found 回答1: I noticed this after trying out the "Conversion to Swift 4.2" button (which failed for me). When I switched to another target where I didn't run this yet, the project built without problems. And after cleaning the project properly , the failing target worked again. Please note that according to the Release

Shiro-菜鸟实战篇-自定义Realm

五迷三道 提交于 2019-12-23 08:56:02
Realm SecuritManager(安全管理器)进行安全认证需要通过Realm获取用户权限数据 Realm也是一个接口,有多种实现: 1、将用户的权限信息写到配置文件 2、将用户的权限信息存储到数据库 Realm 从配置文件或者数据库等读取用户的权限信息 而Shiro自己封装的Realm只能从配置文件读取信息,而用户的认证和授权信息一般存储在关系型数据库中,方便我们维护相关信息。基于这一点,我们可以自定义Realm,下面来分析一下。 自定义Realm-继承 AuthorizingRealm 你要问我为什么要继承AuthorizingRealm?我是不会告诉你的,来看下图继承关系。 可以看出shiro框架所封装好的方法是new IniRealm(“classpath:xxxx.ini”); 那么,我们下面通过几张图来扒一扒它的"祖宗"。 那么相信你现在懂得为什么要继承AuthorizingRealm了。 现在我们就进行编写自定义的Realm类。 public class ShiroRealm extends AuthorizingRealm { protected AuthorizationInfo doGetAuthorizationInfo ( PrincipalCollection principalCollection ) { return null ; }

Change datatype of Realm field - Java

天涯浪子 提交于 2019-12-23 08:52:20
问题 I would like to change the data type of a Realm field from String to int and FYI the field is also a Primary Key . I couldn't find a method in RealmMigration to solve this issue. PS : My app is already in production and all the values that are currently in that field are integers. EDIT 1 My Model class public class Team extends RealmObject { @SerializedName("id") @PrimaryKey private int id; @SerializedName("name") private String name; @SerializedName("description") private String description;

Exclude temporary Realm files from Gradle build

半腔热情 提交于 2019-12-23 08:50:23
问题 Realm provides a database viewer called "Realm Studio" that allows users to browse the contents of their database. When the application is used to view a database, it creates several "temporary" files in the directory of the database, namely: A .realm.lock file. A .realm.note file. A .realm.management directory containing: A access_control.control.mx file. A access_control.new_commit.cv file. A access_control.pick_writer.cv file. A access_control.write.mx file. In the context of Android, a

RealmSwift RLMException

霸气de小男生 提交于 2019-12-23 08:49:11
问题 I am using RealmSwift for my project. However, I'm not sure how to tackle the following: RMLException : Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first thrown. Anyone any clue? import RealmSwift func createOrUpdateMachineInRealm(machine: Machine){ let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT dispatch_async(dispatch_get_global_queue(priority, 0)) { // do some task let realm = Realm() realm.beginWrite() realm.write{ realm

数据驱动的过程调度

三世轮回 提交于 2019-12-23 08:21:48
一:引言 数据驱动的编程方法可以根据不同的数据类型灵活的控制执行逻辑,但目前这种编程方法中并未引入调度技术,待执行的逻辑序列固定编码在执行程序中,虽然可以将数据与过程的对应关系抽取出来,单独放在数据库或者采用类似脚本的动态语言进行控制增加灵活性,但如果数据与过程的对应关系不能固定(比如需要根据某种规则决定执行的过程),或者过程执行需要存储状态(比如需要等待其它数据或者挂起等),现有的处理方法不再适用,需要引入调度机制。 数据驱动的过程调度包含数据对象,过程(函数)对象和调度器,数据和过程(函数)作为对象可以被调度,过程(函数)不再固定的位于某个或者某些逻辑处理序列中。过程对象的调度由数据对象驱动,具有对输入和输出数据对象类型的表述和用于调度的上下文。过程对象的描述类似于函数原型定义,只不过在函数原型定义中,输入和输出的类型未限定,可能过于泛化(比如:函数输入字符串,这个字符串可能具有众多含义,可能是URL,可能是格式化数据,可能是普通文本,或者具有某些含义的序列),而且函数执行逻辑的过程中与环境之间没有约束(比如:引用或者修改全局变量),其本身也不具备调度相关的状态记录,导致可调度能力非常弱,目前的调度大多都是基于线程粒度的调度。很多现代编程语言支持反射方法,可以获取函数原型的表述,虽然实现起来复杂一些,但可以支持函数的调度,不过,由于缺乏或者没有明确限定输入和输出数据对象的含义

Realm Swift 0.92.3 “Run Script Phase” not working

穿精又带淫゛_ 提交于 2019-12-23 07:48:14
问题 Trying to use the new realm-swift-0.92.3, I can't get this “Run Script Phase” to work. I follow the instructions from here. My Run-Script entry according to the the instructions is (see image below): Unfortunately, I still get the following error message while trying to compile (see below). What could still be wrong ??? bash: /Users/XXX/Library/Developer/Xcode/DerivedData/MyAppglnkfueqyjbdhurfurfkip/Build/Products/Debug-iphonesimulator/MyApp.app/Frameworks/RealmSwift.framework/strip