Comments (10)
It's not a crazy idea. We have been planning on supporting a generalized dictionary type with query support (where values can be any supported type) across all the bindings but it has been lower on the list of priorities.
If you want support for any valid JSON, then you would also need support for arrays, which goes beyond what we have previously discussed. The easiest way to make this work would be to store your data it in a string property, and to add a wrapper property to get/set your json object which automatically converts to/from the stored string property. Something like this:
function MyObject() {}
MyObject.prototype.schema = {
name: 'MyObject',
properties: [
{name: 'jsonString', type: RealmType.String},
]
};
Object.defineProperty(MyObject.prototype, "json", {
get: function() { return JSON.parse(this.jsonString); },
set: function(val) { this.jsonString = JSON.stringify(val); }
});
from realm-js.
Has nothing been done for this? Why was this closed? The solution posted by @alazier doesn't appear to work anymore.
I have nested JSON objects coming from an API; some of those fields are simple JSON. I have no need to search the JSON fields, I merely want to read and write it naturally without needing to serialize/deserialize manually.
from realm-js.
@ismdcf if you want to store larger blocks of data you will need to break it up into smaller pieces or store it outside of Realm.
from realm-js.
Yeah, that's what I did last night.
Working well.
from realm-js.
So what about the second problem
Is there a string size limit? I see something about 16 MB in the docs for a property.
will the string size create an issue.
from realm-js.
@alazier Is there a new solution for this? I also want to store a JSON value that will constantly change and contain arrays and such. Is using string still the best method?
from realm-js.
@brunobraga95 no new solution as of yet.
from realm-js.
@alazier does that mean everytime I need to do a write/query I will have to retrieve and save the whole data?
from realm-js.
I have JSON comming from API it contains the fields whose data type is String and Object.
How to store this nested JSON in realm DB column
from realm-js.
@karthikpala This doesn't seem closed, could please expain the fix
from realm-js.
Related Issues (20)
- 'object type 'f' not found in schema' occurs when updating the application via code push appcenter HOT 4
- Remapped Property Key Not Working with Sorting HOT 1
- Keep login information persistent with 12.0.0-browser.2 HOT 3
- toJSON() serialization of BSON.ObjectId to String HOT 1
- `@realm/react`: Passing an app as a prop to `AppProvider` HOT 1
- Error: Database has an unsupported version (24) and cannot be upgraded HOT 2
- Gradle lint error with 12.10.0 and yarn errors with 12.11.1 HOT 4
- Unable to resolve "../../../realm/lib/browser$1" from "node_modules/@realm/react/dist/index.cjs" HOT 3
- Sync protocol version issue in 12.0.0-browser.2 HOT 3
- Add `useProgress` to `@realm/react` HOT 1
- Add `useProgress` to `@realm/react` HOT 4
- Improve Electron support by allowing renderer process "context isolation" and disabled "node integration" HOT 9
- Could not find realm binary when show react-native component in native iOS app HOT 1
- Realm does not build on iOS with `use_frameworks! :linkage => :static` as of version 12.12.0 HOT 11
- Add relaxed schema extensions to realm objects via dynamic API HOT 1
- Can't use Realm with new react native architecture HOT 2
- Expo EAS build started failing with command not found: cmake-js HOT 3
- Stabalize `OpenBehaviour` tests HOT 3
- App crashes on RN0.74 when launching HOT 4
- Improve the experience of using setters & getters with embedded objects HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from realm-js.