realm

Swift Realm: After writing transaction reference set to nil

亡梦爱人 提交于 2019-12-30 12:22:15
问题 I have the following code class Family: Object { dynamic var name = "" var members = List<FamilyMember>() } class FamilyMember: Object { dynamic var name = "" dynamic var belongsToFamily: Family? } let realm = try! Realm() let familyMember = FamilyMember() familyMember.name = "NameExample" let newFamily = Family() newFamily.name = "Familyname" try! realm.write { newFamily.members.append(familyMember) familyMember.belongsToFamily = newFamily realm.add(newFamily) realm.add(familyMember) }

Alamofire, Objectmapper, Realm: Nested Objects

流过昼夜 提交于 2019-12-30 09:39:13
问题 I'm using Alamofire, Objectmapper, Realm and everything is working beside one thing: I can't map nested objects. class Voting: Object, Mappable { dynamic var votingID: String = "" dynamic var question: String = "" var votingOptions = List<VotingOption>() required convenience init?(_ map: Map) { self.init() } func mapping(map: Map) { votingID <- map["id"] question <- map["question"] votingOptions <- map["votingOptions"] } override class func primaryKey() -> String { return "votingID" } } class

How to achieve the following in Realm for android

三世轮回 提交于 2019-12-30 08:33:41
问题 In my applications, I usually have a loader that loads the data from sqlite and then passes it on to either the activity or fragment it is attached, from where it is set in the adapter of a absListView which then presents it to the user Since realm states that its objects shouldn't be shared across threads, how can this be achieved without making any db calls from the UI thread? (which would make the app feel sluggish as I hit the db a good amount) Also in the 3 examples - intro, gridView &

Realm For Android详细教程

时光总嘲笑我的痴心妄想 提交于 2019-12-30 04:34:49
目录 1、Realm简介 2、环境配置 3、在Application中初始化Realm 4、创建实体 5、增删改查 6、异步操作 7、Demo地址(https://github.com/RaphetS/DemoRealm ) Demo地址:https://github.com/RaphetS/DemoRealm 一、Realm简介 数据库Realm,是用来替代sqlite的一种解决方案,它有一套自己的数据库存储引擎,比sqlite更轻量级,拥有更快的速度,并且具有很多现代数据库的特性,比如支持JSON,流式api,数据变更通知,自动数据同步,简单身份验证,访问控制,事件处理,最重要的是跨平台,目前已有Java,Objective C,Swift,React-Native,Xamarin这五种实现。 本篇文章用的版本为Realm 2.0.2( 官方文档 ) 二、环境配置 (1) 在项目的build文件加上 buildscript { repositories { jcenter() } dependencies { classpath "io.realm:realm-gradle-plugin:2.0.2" } } (2) 在app的build文件加上 apply plugin: 'realm-android' 三、初始化Realm (1) 在Application的oncreate

composite primary key realm/swift

两盒软妹~` 提交于 2019-12-30 00:50:08
问题 I'm new to swift and realm. I want to make a composite primary key and when I'm trying something like this : class DbLocation : Object { dynamic var id = 0 dynamic var tourId = 0 dynamic var uuid : String { return "\(id)\(tourId)" } override static func primaryKey() -> String? { return "uuid" } } I'm getting this error : 'Primary key property 'uuid' does not exist on object 'DbLocation' Anyone can help me out with an example how to create a composite primary key ? 回答1: For 1.0.1+ of Realm:

shrio框架的realm机制

人盡茶涼 提交于 2019-12-29 14:22:29
Realm的使用: 如果我们希望可以将Shiro校验的用户信息存储在数据库里面,再从数据库里面读取出来。可以通过Shiro的Realm机制实现。 Realm机制就是将配置文件的校验用户信息存放在数据库、LDAP等数据存储系统里面。 Realm事例 第一步:创建项目,导入包 第二步:创建shiro.ini配置文件 [main] #创建一个myRealm对象 myRealm=cn.hzh.realm.MyRealm #将myRealm对象放在SecurityManager容器中 securityManager.realms=$myRealm 第三步:创建入口的测试类对象 public class ShiroTest { public static void main(String[] args) { // shrio框架读取ini配置文件 IniSecurityManagerFactory ismf = new IniSecurityManagerFactory("classpath:shiro-config.ini"); // 获得SecurityManager对象 SecurityManager securityManager = ismf.createInstance(); // 设置一个身份对象Subject SecurityUtils.setSecurityManager

Shiro笔记(四)Shiro的realm认证

為{幸葍}努か 提交于 2019-12-29 14:22:20
认证流程: 1.获取当前Subject.调用SecurityUtils.getSubject(); 2.测试当前用户是否已经被认证,即是否已经登录,调用Subject的isAurhenticated(); 3.若没有认证,则把用户名和密码封装成UsernamePasswordToken对象. 对于B/S应用程序来说,一般用户名和密码是在前台表单中获得的: 1.创建一个表单页面. 2.把请求提交到SpringMVC的Controller. 3.获取用户名和密码. 4.执行登录:调用Subject.login(AuthenticationToken) 方法. 5.自定义Realm方法,从数据库中获取对应的记录,返回给Shiro. 自定义Realm的实现: 1.继承org.apache.shiro.realm.AuthenticatingRealm类. 2.实现doGetAuthenticationInfo(AuthenticationToken)方法. 为什么要继承它且实现它的doGetAuthenticationInfo方法呢?可以跟进源码查看 subject.login(token) 是怎样工作的: subject.login(token) -> securityManager.login(this, token) -> authenticate(token) ->

Realm Auto Increament field example

爱⌒轻易说出口 提交于 2019-12-29 06:50:10
问题 I need to add auto increment key field in Realm database in android. how can i do this? Is this possible? Thanks in advance. 回答1: Relam currently doesn't support auto_increment see this issue on GitHub you can take work around like this realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { // increment index Number num = realm.where(dbObj.class).max("id"); int nextID; if(num == null) { nextID = 1; } else { nextID = num.intValue() + 1; } dbObj obj =

How to add the parent path to RealmSwift.framework in the “Framework Search Paths” section?

蹲街弑〆低调 提交于 2019-12-29 04:56:27
问题 This is step is listed in the instructions for installing Realm. link here: https://realm.io/docs/swift/latest/ I am new to xcode and I don't understand how to complete this step. Can someone give me detailed instructions? I found the Framework Search Paths section in the build settings, but I don't even know what it means to add a parent path. I also need help with the next step, creating a new run script phase. xcode ver 6.4 回答1: If you follow to 2nd step correctly, the project directory

JDBC Realm Form Authentication How To [duplicate]

假如想象 提交于 2019-12-28 19:19:34
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: JDBC Realm Login Page Hello to all, i would like to create an application login feature which bundled with jdbc realm and with custom login form(Form based authentication login constraint method). Please provide a link or any help is greatly appreciated. Please help. Thanks. 回答1: What kind of container are you using?jBoss?Tomcat?Derby? You also need to make use of persistent storage -> yes DBMS is needed. Which