Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realm Result/Object -> String is broken #2042

Open
TheNoim opened this issue Sep 28, 2018 · 2 comments
Open

Realm Result/Object -> String is broken #2042

TheNoim opened this issue Sep 28, 2018 · 2 comments
Labels
First-Good-Issue First Good Issue - Relatively easy issue for new contributers O-Community T-Feature

Comments

@TheNoim
Copy link

TheNoim commented Sep 28, 2018

Goals

Be able to stringify a realm result for an http api

Expected Results

A list of objects like defined in the models

Actual Results

Arrays are Objects
{ "0": "Array Item 1", "1": "Array Item 2" }

Steps to Reproduce

Create any realm model (At least one property List) and stringify the result of any query.

Code Sample

const Job = {
    name: 'Job',
    primaryKey: 'id',
    properties: {
        id: 'string',
        qualification: {
            type: 'string?[]',
            default: []
        }
    }
};
// open realm with model and add an example

// example:
const job = {
    id: "wtf",
    qualification: ["whatever"]
}

// add to realm

// query
const results = realm.objects("Job");

console.log(JSON.stringify(results));
/*
{
   "0": {
       "id": "wtf",
       "qualification": {
           "0": "whatever" 
       }
   }
}
*/

Please, add an option to convert a realm result/object to a plain javascript object or an method to stringify results. Of course there are workarounds, but all of this makes it hard to use realm.

Version of Realm and Tooling

  • Realm JS SDK Version: 2.17.0

Btw do not forget #2018 good idea to fix both

@TheNoim
Copy link
Author

TheNoim commented Sep 30, 2018

@bmunkholm bmunkholm added T-Feature First-Good-Issue First Good Issue - Relatively easy issue for new contributers labels Oct 2, 2018
@bmunkholm
Copy link
Contributor

This seems like a task anyone with interest in helping out could take, so added the "Help Wanted" tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-Good-Issue First Good Issue - Relatively easy issue for new contributers O-Community T-Feature
Projects
None yet
Development

No branches or pull requests

4 participants