realm

Realm query with List

北战南征 提交于 2019-11-29 13:51:15
I'm using realm to store my data on Android. Awesome framework! Now the only problem I'm now having is: I got a array list strings with id's of Countries in my database. Now I retrieve my Drinks that contains a relationship to countries. Is there a way that I could to do a query like this: String [] ids; realm.where(Drinks.class).equalsTo("country.id", ids); Something like that? Or do I really need to do a query to get me all drinks and then filter the list manually? EDIT: My classes: public class Drinks extends RealmObject { @PrimaryKey private String id; private String name; private Country

iOS Realm Filter objects in a list of a relationship

北城余情 提交于 2019-11-29 11:43:25
问题 I have three objects nested via lists like this: class Canteen: Object { dynamic var name: String? let lines = List<Line>() } class Line: Object { dynamic var name: String? let meals = List<Meal>() } class Meal: Object { dynamic var name: String? dynamic var vegan: Bool = false } Getting all canteens with all the lines and meals is no problem. What im doing right now is this: let predicate = NSPredicate(format: "name == %@", selectedCanteenType.rawValue) canteens = realm.objects(Canteen)

Realm - Share Database between Apps

↘锁芯ラ 提交于 2019-11-29 11:40:33
So I have a application that is comprised of 3 APK/Apps. How do I share the database between apps? I am assuming the reason it is currently not visible between the apps is because they are passing in different contexts. Thanks Christian from Realm here. Currently what you are asking is really not feasible. As others have pointed out there is really only two approaches. 1) Expose a ContentProvider. However that require you to map RealmResults to a Cursor which is not a trivial effort. We are planning on exposing a RealmCursor down the line, but other things have had priority so we havn't looked

Android Realm large file size

人盡茶涼 提交于 2019-11-29 10:55:19
I am new to android programming. I implemented Realm for my simple grade tracker, however, the file size has grown from 1.5mb to 5mb. Is that normal? What I simply did was add in an instance of realm on every class with oncreate, added in realm.close() whenever there was a chance that the activity would end. Also wrapped the begin and commit transaction around each object creation. Is there something I did wrong that ended up with the massive file size? Thanks! Edit: I mean apk size @geisshirt is right. Realm have introduced the method public static boolean compactRealm(RealmConfiguration

Realm dotnet - The rhs of the binary operator 'Equal' should be a constant or closure variable expression

ⅰ亾dé卋堺 提交于 2019-11-29 10:50:53
Hi have just started using Realm dotnet When I perform a simple query like var results = realm.All<MyRealmType>().Where(x => x.Property == otherVariable.Property); So in the Where clause I am comparing two strings to retrieve the data I need from the realm. I get the following error {System.NotSupportedException: The rhs of the binary operator 'Equal' should be a constant or closure variable expression at Realms.RealmResultsVisitor.VisitBinary (System.Linq.Expressions.BinaryExpression b) [0x000cb] in <filename unknown>:0 at Realms.ExpressionVisitor.Visit (System.Linq.Expressions.Expression exp

How to load thousands records to Realm correctly?

孤街醉人 提交于 2019-11-29 10:23:09
问题 I'm trying to save about 8000 records into the disk, using Realm, but it's blocking UI. As a result, I use Realm.asyncOpen that performs data saving in background thread. The problem is 100% CPU usage when I try to save big amount of records this manner. How to load thousands records to Realm correctly? 回答1: Try the way in official demo to save large amounts of data: DispatchQueue(label: "background").async { autoreleasepool { // Get realm and table instances for this thread let realm = try!

Share realm between different users on Realm Object Server?

旧城冷巷雨未停 提交于 2019-11-29 09:31:17
问题 Is there currently a way to allow multiple users to access the same Realm? Right now the only way I could find is to use an 'app account' instead of an user account, as proposed in another question. thanks! 回答1: In general, you can connect to a Realm file at a virtual path. They must be always absolute, so begin with a leading slash / and never carry a file suffix. Realms at a file name with two leading underscores are considered internal state of the Realm Object Server and have special

SpringBoot 优雅的整合 Shiro

a 夏天 提交于 2019-11-29 08:18:15
Apache Shiro是一个功能强大且易于使用的Java安全框架,可执行身份验证,授权,加密和会话管理。借助Shiro易于理解的API,您可以快速轻松地保护任何应用程序 - 从最小的移动应用程序到最大的Web和企业应用程序。网上找到大部分文章都是以前SpringMVC下的整合方式,很多人都不知道shiro提供了官方的starter可以方便地跟SpringBoot整合。 请看shiro官网关于springboot整合shiro的链接:Integrating Apache Shiro into Spring-Boot Applications 整合准备 这篇文档的介绍也相当简单。我们只需要按照文档说明,然后在spring容器中注入一个我们自定义的Realm,shiro通过这个realm就可以知道如何获取用户信息来处理鉴权(Authentication),如何获取用户角色、权限信息来处理授权(Authorization)。如果是web应用程序的话需要引入shiro-spring-boot-web-starter,单独的应用程序的话则引入shiro-spring-boot-starter。 依赖 <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring-boot-web-starter<

Realm Change Listener with RealmResults not being called

戏子无情 提交于 2019-11-29 07:46:52
I'm using Realm 3.0.0 I'm fetching some objects from Realm and trying to add onChangeListener, but it does not get fired when an object is changed Here's the code, am I missing something here? RealmResults<Record> realmResults = RealmManager.recordsDao().loadRecords(); realmResults.addChangeListener(new RealmChangeListener<RealmResults<Record>>() { @Override public void onChange(RealmResults<Record> element) { for (int i = 0; i < recordList.size(); i++) { if (collection.get(i).getId().equals(recordList.get(i).getId())) { recordList.set(i, collection.get(i)); adapter.notifyItemChanged(i); } } }

Kotlin data class of RealmObject

房东的猫 提交于 2019-11-29 04:56:28
问题 I'm using Kotlin and Realm to write a data class data class AuthToken(val register: Boolean, val token: String, val tokenSecret: String, val user: AuthUser) I have to save the data to db, so I use Realm to save it. But as we know, if I want to save the class to Realm, the AuthToken class has to extend RealmObject . That's the problem, Kotlin says data classes can't extend classes. so I give up data class, just using a normal Kotlin class as a model then another question comes: Kotlin class