question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for primitive lists

See original GitHub issue

@alazier I am unable to create a list of only string objects

This is how my model looks like

class ProductSummary extends Realm.Object {}
ProductSummary.schema = {
name: 'ProductSummary',
properties: {
    productId:'string',
    name:'string',
    description:'string',
    rating:'int',
    comments:'int',
    categories:{type:'list',objectType:'string'},
    images:{type:'list',objectType:'string'},
    price:{type:'Price'}
   }};

This is how the response looks like "productSummary": { "links": [], "productId": "PRD_1ola611nd0t", "name": "Sample", "description": "<p>Sample<br></p>", "categories": [ "CAT_1rua60fnd0u" ], "rating": 0, "comments": 0, "tags": [], "image": "http://test.testsite.com/testProject/app-images/189_66164247/189_42527954.jpeg", "price": { "lowest": 100, "highest": 100 } }

In realm for android there is a way to wrap these types of primitive lists how could I do this using realm js

Error Message

 `Target Type 'string' doesn't Exists for property 'categories'`

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

12reactions
LeoArefcommented, Mar 27, 2017

I think this feature is a must! It’s not practical to that trick and transform all the string list to {value: 'string} list

1reaction
alaziercommented, Aug 2, 2016

This is definitely something we hope to add. For now you have to create an object to wrap your primitive type:

let StringObjectSchema = {
    name: 'StringObject',
    properties: { value: 'string' }
};

class ProductSummary extends Realm.Object {}
ProductSummary.schema = {
name: 'ProductSummary',
properties: {
    ...
    categories:{type:'list', objectType:'StringObject'},
    images:{type:'list', objectType:'StringObject'},
    ...
   }};

Its a bit annoying as when creating/accessing string objects you need to access/set the value property which might require some data transformation when importing or exporting data.

Read more comments on GitHub >

github_iconTop Results From Across the Web

List of Primitive Integer Values in Java - Baeldung
In this quick article, we showed multiple ways of creating lists with the primitive integers. In our examples, we used the Trove, Fastutil,...
Read more >
Eclipse Collections Now Supports Indirect Sorting of Primitive ...
Eclipse Collections Now Supports Indirect Sorting of Primitive Lists. Sometimes the best way to get results is to be indirect. Matryoshka dolls ...
Read more >
Create a List of primitive int? - java - Stack Overflow
Is there a way to create a list of primitive int or any primitives in java like following? List<int> myList = new ArrayList<int>();...
Read more >
Support of primitive types for List · Issue #5489 - GitHub
Note that querying Lists containing primitive values is currently not supported. This is actually not an issue, primitive types in queries ...
Read more >
Primitive Data Types (The Java™ Tutorials > Learning the ...
The eight primitive data types supported by the Java programming language are: byte: The byte data type is an 8-bit signed two's complement...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found