Comments (4)
Hi @ironage
Understood and yeah the other table will work for me. Thank you. You can close the issue.
from realm-js.
Hi @gauravbordoloi we don't currently support sorting or distinct on a collection. What do you expect the behaviour of distinct to be, given dictionaries with the following sets of keys: {a, b, c}, {a, b}, {c}
? When talking about comparing collections, we usually need to specify the match behaviour: ANY/ALL/NONE. So then we might be looking for syntax like DISTINCT(ALL attributes)
? Is that the feature you are looking for?
from realm-js.
Hi @ironage , I have multiple data like these,
[
{
"name": "Levis Shirt",
"attributes": {
"color": "White",
"size": "XL"
}
},
{
"name": "Nike Shirt",
"attributes": {
"color": "Red",
"size": "L"
}
},
{
"name": "Adidas Shirt",
"attributes": {
"color": "Black",
"size": "XXL"
}
}
]
What I want to do is
- fetch all the attribute keys without duplicates - Result (color, size)
- fetch all the attribute values for a particular key without duplicates- Result (color=White,Red,Black)
2nd point, I am able to get the data using the query
//attr = "color"
realm.objects(ProductModel).filtered(`status == $0 DISTINCT(attributes['${attr}'])`, "PUBLISH")
but for the 1st point, nothing is working. I tried the below code but it doesn't work
realm.objects(ProductModel).filtered(`status == $0 DISTINCT([email protected]`, "PUBLISH")
from realm-js.
@gauravbordoloi we don't currently support the query you are trying to do. Fundamentally, our query system produces matching objects, not a collection of matching properties. I think what you want is an advanced use of projections.
A solution for you today would be to also insert your keys into an independent class that tracks unique keys. So every time you insert into the attribute
dictionary, you could also call
realm.create("AllKeys", {_id: "myKey"}, UpdateMode.Modified); // UpdateMode.Modified makes this an upsert
Insertion/lookup is fast because a primary key is indexed. Then to get all keys, you iterate over all objects of this class
realm.objects("AllKeys");
Would this work for you?
from realm-js.
Related Issues (20)
- Upgrade to BSON v6 HOT 2
- Jest test: "Cannot find module 'realm'" HOT 11
- Expose an API that allows merging collections rather than replacing them HOT 1
- Bundling with Metro warns with "Require cycles are allowed, but can result in uninitialized values." HOT 1
- Handle Role Changes without Client Reset HOT 1
- Upgrade to Realm Core 14.4.0 HOT 1
- Upgrade to Realm Core 14.4.1 HOT 1
- React Native Android application crashing when using syncSession.addConnectionNotification HOT 9
- getSyncSession cannot resolve session even though it exsist HOT 6
- [realm/react] Account for new `ObjectId` refs used in the dependency list HOT 6
- Multi-threaded support for Electron / NodeJS HOT 3
- baseUrl Change (Realm Web) HOT 1
- Calling `User#linkCredentials` with the email of a non-existing user or wrong password never surface error HOT 1
- "free(): invalid pointer" when running on Ubuntu x86_64 and Node.js >= v20.12.0 HOT 4
- Ensure we have `clang-format` installed on CI runners when generating bindings HOT 2
- Upgrade to Realm Core 14.5.0 HOT 1
- Random SIGSEGV error and crash on production HOT 2
- Error Realm initialization with sync enabled due to mismatch schema is not calling onError function HOT 2
- Version mismatch does not block sync HOT 5
- Run React Native integration tests in more configurations HOT 2
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.