realm

how to convert RealmSwift List to Results?

做~自己de王妃 提交于 2019-12-05 02:47:06
I am using a Realm List/Results as my dataSource for a UITableView . At some point I assign a list to it. like: var dataSource:List<SomeObject>! // Or >> Results<SomeObject>! let aRealmObject = realm.objectForPrimaryKey(SomeObject.self, key: objectId) dataSource = aRealmObject.someList // dataSource should be List Then I have a filter on this list If the user changed the filter dates, I do like this: dataSource = dataSource.filter("FILTER THE DATES",newDates) // dataSource should be Results But the line above causes an error as the return type of filter is a Results object and aRealmObject

Saving Array to Realm in Swift?

廉价感情. 提交于 2019-12-05 01:38:11
Is it possible to save an array of objects to Realm ? Anytime I make a change to the array it should be saved to Realm. My current solution is to save object for object with a for loop . For append/modifying objects calling save() will do the job, but not when I remove an object from it. class CustomObject: Object { dynamic var name = "" dynamic var id = 0 override static func primaryKey() -> String? { return "id" } } struct RealmDatabase { static var sharedInstance = RealmDatabase() var realm: Realm! let object0 = CustomObject() let object1 = CustomObject() var array = [object0, object1] init

How can I bundle a Realm database file with my app to deploy with installation

女生的网名这么多〃 提交于 2019-12-05 01:18:20
问题 I have a data set of around 50k records which I want to put in a Realm database. I am unsure of how can I make this DB in Realm and bundle it with the App so that the file can reside from the very start (installation) in the device. 回答1: You can put a Realm file in your assets folder and copy it the first time you open the app. There is an example on how to do that here: https://github.com/realm/realm-java/blob/master/examples/migrationExample/src/main/java/io/realm/examples

base-framework 工程文档收录

百般思念 提交于 2019-12-05 01:12:07
1 shrio 实用功能说明 apache shiro 是功能强大并且容易集成的开源权限框架,它能够完成认证、授权、加密、会话管理等功能。认证和授权为权限控制的核心,简单来说,“认证”就是证明“你是谁?” Web 应用程序一般做法是通过表单提交的用户名及密码达到认证目的。“授权”即是"你能做什么?",很多系统通过资源表的形式来完成用户能做什么。关于 shiro 的一系列特征及优点,很多文章已有列举,这里不再逐一赘述,本文首先会简单的讲述 shiro 和spring该如何集成,重点介绍 shiro 的几个实用功能和一些 shiro 的扩展知识。 1.1 shiro 集成 spring 由于 spring 在 java web 应用里广泛使用,在项目中使用 spring 给项目开发带来的好处有很多,spring 框架本身就是一个非常灵活的东西,而 shrio 的设计模式,让 shiro 集成 spring 并非难事。 首先在web.xml里,通过 spring 的 org.springframework.web.filter.DelegatingFilterProxy 定义一个 filter ,让所有可访问的请求通过一个主要的 shiro 过滤器。该过滤器本身是极为强大的,允许临时的自定义过滤器链基于任何 URL 路径表达式执行。 web.xml: <!-- shiro

Cannot load underlying module for 'RealmSwift'

孤人 提交于 2019-12-05 01:11:47
I'm trying to install Realm for Swift via Cocoapods. First what I did was pod init into my project Then I open podfile and changed it like this: target 'Taskio' do use_frameworks! pod 'RealmSwift' end Then I closed podfile and execute command pod install Everything pass good. But now when i opened workspace I'm getting error while importing RealmSwift Cannot load underlying module for 'RealmSwift' Firstly try to check what workspace you open after cocoapods were install open App.xcworkspace file.If yes open Pods directory and check if file is actually installed by manually navigation to REALM

shiro实现多用户表多Realm统一登录认证

风流意气都作罢 提交于 2019-12-05 01:11:25
前言 说明一下需求,最近做的平台,有多张用户表,怎么根据不同用户登录去执行自己查询不同数据库并实现认证的业务逻辑呢? 博主参与的产品开发进入阶段性完成期,有时间将过程中遇到的相关问题一一总结。 总结 实现本需求,首先是从Subject入手,它是完成shiro登录过程的入口,login(UsernamePasswordToken)方法完成用户名密码传递,后面自己实现Realm去认证登录,关键就在如何区分这些用户名密码是对应哪个数据库表,若有一个状态去判断它们,则可以解决问题。 设计上的反思 其实从实际参与这个大产品开发之后,越来越发现,它不便于我们对各类用户的管理,虽然做了很多针对shiro的扩展去实现自己想要的功能,但渐渐明白为什么shiro不提供这样的解决方案。 这里,博主也建议,用户表可以有多个,但登录认证的表其实只保留一个就好,将你的多Realm抽象出来一个关系表映射,将各种状态加入,登录等认证交由统一维护,具体信息查询等封装抽象,下面做对应实现即可,这样才应该是跨平台的,以后也只需要存储跟别的平台的用户关系绑定,就完成了登录。 正文 shiro标准的登录过程是用户在Controller里创建UsernamePasswordToken对象,然后绑定上前端访问过来的账号密码,之后由Subject.login(UsernamePasswordToken)完成登录

Realm Swift2: Best practice for model and Realm model class separation

蹲街弑〆低调 提交于 2019-12-05 01:00:00
I just have started working with Realm for Swift. After reading the documentation, still I have a couple of question marks in mind. My biggest one is, if there is a best practice for separation Model classes from Realm classes. For example, in Java MVC projects we used DAO classes (Data Access Object classes) which were responsible for the communication with the database layer. Our corresponding model classes only have either the dao object injected or we used service classes for this (like CRUD operations). If I habe a Realm “Model” class, this seems now to be everything in one. But after

RealmList of String Type in Android

泄露秘密 提交于 2019-12-04 23:46:52
I'm using Realm for Local storage in Android. I'm getting following response form server. [{ "ListId": 10, "Names": ["Name1", "Name2", "Name3", "Name4"] }] Here is my Model public class Model extends RealmObject { private int ListId; private RealmList<String> Names = new RealmList<String>() public int getListId() { return ListId; } public void setListId(int listId) { ListId = listId; } public RealmList<String> getNames() { return Names; } public void setNames(RealmList<String> names) { Names = names; } } And I'm getting this for ArrayList Type parameter 'java.lang.String' is not within its

How do you compact a Realm DB on iOS?

ぐ巨炮叔叔 提交于 2019-12-04 23:02:01
问题 I'd like to compact a Realm instance on iOS periodically to recover space. I think the process is to copy the db to a temporary location, then copy it back and use the new default.realm file. My problem is Realm() acts like a singleton and recycles objects so I can't really close it and tell it to open the new default.realm file. The docs here (https://realm.io/docs/objc/latest/api/Classes/RLMRealm.html) suggest I wrap all the Realm() calls in autorelease { } but it can't be this complicated.

Design Pattern for Realm Database Swift 3.1 - Singleton

烈酒焚心 提交于 2019-12-04 21:28:42
I'm working on RealmSwift , which is a modern database replacement of CoreData/SQLite in Swift. I'm wondering how to implement a design for a Class which can manage/handle all the queries for RealmSwift Framework This question is somewhat similar to implementing SQLite Model Manager but for RealmSwift. Specifically I don't require a singleton object/instance mention above. Realm has a rather clever internal caching system where previous instances of Realm are held onto and recycled each time a call like let realm = try! Realm() occurs. As such, it's not really necessary, nor recommended to try