realm

Saving array of objects in Realm with Decodable

99封情书 提交于 2019-12-25 01:18:08
问题 I've got a class which conforms to Decodable protocol (fetching data from API) and I would like to save it in the Realm database. Problem occurs when one of my properties is array (List). It says Cannot automatically synthesize Decodable because List<Item> does not conform to Decodable What is the best way to bypass this problem? Realm only supports arrays of primitive types. here is my class: class PartValue: Object, Decodable { @objc dynamic var idetifier: Int = 0 let items = List<Item>() }

How to save model data using realm?

 ̄綄美尐妖づ 提交于 2019-12-25 01:07:22
问题 I am developing a chat app and successfully saved User model class to the realm but now I want to save messages to the realm so that when user start app able to see previous chat history and messages. below my SavedMessages model class @RealmClass public class SaveMessage extends RealmObject { private int mId; private String mUsername; private String mContent; private Date mCreatedAt; private boolean mRightMessage; private String mPictureString; private String mType; public SaveMessage(int id

Not notify Fragment when remote Realm (on Realm Object Server) was changed

眉间皱痕 提交于 2019-12-25 00:14:58
问题 When I start Android app I login to Realm Object Server and download (sync) data from Realm Server Object. OK. Now I got to Fragment that show list of persons. Here code: public class PersonsFragment extends Fragment { private ListView notEmptytsListView; private Realm realm; private RealmResults<Person> personsRealmResults; private PersonsAdapter personsAdapter; // RealmBaseAdapter<Organization> private RealmChangeListener realmChangeListener; @Nullable @Override public View onCreateView

Realm insertion of JSON object takes 60ms per object

谁都会走 提交于 2019-12-24 19:41:42
问题 I have the following json object : https://pastebin.com/B9Z1Wmqd Currently using Realm 2.0.2 My relevant objects (simplified) are as follows so you can see the mapping : Top level object: public class PlannedTaskDao extends RealmObject { @PrimaryKey private Long tasks_id; private Date date; private Date lastUpdate; private Long clients_id; private String hour; private String libelle; private String comments; private Boolean closed; private int displayOrder; private long executionTime; private

RealmSwift Cannot cast Results<SomeOjbect> to Results<Object>

a 夏天 提交于 2019-12-24 19:13:51
问题 RealmSwift version: latest master branch So I have a Realm Object like: import RealmSwift class SomeObject: Object { @objc dynamic var datetime = "" @objc dynamic var city = 0 convenience init(city: Int, datetime: String) { self.init() self.city = city self.datetime = datetime } } There is a func call like static func createlineData(from results: Results<Object>?) -> LineChartData Now I fetch some results and pass to createLineData : let realm = try! Realm() let results = realm.objects

cannot read property 'default' of undefined

耗尽温柔 提交于 2019-12-24 19:13:49
问题 Getting this error on the this.realm = line below. Not sure why as this code worked when it was formatted as a factory function import Realm from 'realm'; export default function Db() { this.realm = new Realm({ schema: [Wallet, WalletAddress, WalletTransaction, Log, APIWallet, APITransaction, APIAccount, Configuration], path: config.db_path }); logger(2, realm.path); } Db.prototype.doOneToMany = function(one, many) {..}; Db.prototype.query = function(model, filter) {..}; Db.prototype.insert =

Apache Shiro系列一,概述 —— 初识

こ雲淡風輕ζ 提交于 2019-12-24 19:05:39
Shiro的设计目标就是让应用程序的安全管理更简单、更直观。 软件系统一般是基于用户故事来做设计。也就是我们会基于一个客户如何与这个软件系统交互来设计用户界面和服务接口。比如,你可能会说:“如果用户登录了我们的系统,我就给他们显示一个按钮,点击之后可以查看他自己的账户信息。如果没有登录,我就给他显示一个注册按钮。” 上述应用程序在很大程度上是为了满足用户的需求而编写的,即便这个“用户”不是人,而是一个其他的软件系统。你仍然是按照谁当前正在与你的系统交互的逻辑来编写你的逻辑代码。 Shiro的设计已经考虑到以上这些用户安全的概念。 总览 在最顶层,Shiro的架构有3个主要概念:Subject、SecurityManager和Realms。下图展示了这几个组件之间的交互,下面我们会逐一介绍这些概念: #,Subject,正如我们在 教程 中所说,Subject其实代表的就是当前正在执行操作的用户,只不过因为“User”一般指代人,但是一个“Subject”可以是人,也可以是任何的第三方系统,服务账号等任何其他正在和当前系统交互的第三方软件系统。 所有的Subject实例都被绑定到一个SecurityManager,如果你和一个Subject交互,所有的交互动作都会被转换成Subject与SecurityManager的交互。 #,SecurityManager

Realm in IOS: Primary key can't be changed after an object is inserted

夙愿已清 提交于 2019-12-24 18:23:03
问题 I'm some new in using Realm. I've some code: RLMRealm *realm = [RLMRealm defaultRealm]; [realm transactionWithBlock:^{ self.object.objectPrimaryKey = someValue; }]; An exception occures on this string: self.object.objectPrimaryKey = someValue; with reason: 'Primary key can't be changed after an object is inserted.' objectPrimaryKey is a primary key. What can I do to fix it? 回答1: docs about primary key, you can set primary key only once. You can't change key once it's set: Override Object

realm cocoa: is it possible to do queries on links

若如初见. 提交于 2019-12-24 14:21:51
问题 On the following object model: // Dog model class Dog: RLMObject { var name = "" var owner = Person() } // Person model class Person: RLMObject { name = "" birthdate = NSDate(timeIntervalSince1970: 1) dogs = RLMArray(objectClassName: Dog.className()) } is it possible to query for all person's who have a dog whose name starts with 'B' i.e. something like Person.objectsWhere("ANY dogs.name name BEGINSWITH 'B'") I have tried it, doesn't seem to work on realm-cocoa 0.89.1 回答1: This should work,

Realm retrieving specific data

亡梦爱人 提交于 2019-12-24 14:21:49
问题 Good Day! I started using Realm.io Database for iOS 3 days ago. I can store data from the app to the database. But Retrieving it gives me headache. My problem is i cannot select specific data on database. I'm using this to get the data RLMResults *data = [MapLocationCoordinates allObjects]; NSString *rawData = [NSString stringWithFormat:@"%@",[data objectAtIndex:0]]; NSLog(@"%@",rawData); Now the result: 2015-05-07 05:31:01.554 Sample App[2401:79922] MapLocationCoordinates { objectId =