-
Notifications
You must be signed in to change notification settings - Fork 115
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
Sub-Objects in class not populated when using projection (QXMONGODB) #127
Comments
If, on the other hand, I change all data types with Change in class TEST_DLL_EXP collection_1
{
public:
QString m_id;
QVariant m_a;
QVariant m_b;
QVariant m_c;
collection_1(){}
virtual ~collection_1(){}
}; In this case, using [QxOrm] sql query (total: 0.263 ms, db_exec: 0.254 ms) : MongoDB find many 'collection_1' :
{ "projection": { "a": 1, "b": 1, "c": 1 } }
[
{
"_id": "qx_oid:663b23d9ff912c570a093b91",
"a": {
"someStuff": "ssa_1"
},
"b": {
"someStuff": "ssb_1"
},
"c": [
{
"someStuff": "ssc_1"
},
{
"someStuff": "ssc_2"
},
{
"someStuff": "ssc_3"
}
]
}
] |
Similarly, if I use |
Hello, I think the issue is here :
For m_a, m_b, and m_c, you should register them as relationships. |
db.collection_1.find() Result: {
"_id": ObjectId("663b23d9ff912c570a093b91"),
"a": {
"someStuff": "ssa_1"
},
"b": {
"someStuff": "ssb_1"
},
"c": [
{
"someStuff": "ssc_1"
},
{
"someStuff": "ssc_2"
},
{
"someStuff": "ssc_3"
}
]
} As you see, I only used a simple find query and the data is all stored in a single collection (~table). Also, I haven't used MongoDB can store objects inside objects, contrary to SQL DBs, which is probably why this is being different. Also, as I stated, this works when I don't add the "projection" (columns argument). If I use a relation, won't it just try to look for data in another collection which is not in the database? |
Hello, You should try to create a persistable custom type : if you do that, you don't need to use relationship to link to other classes. The most important is this implementation :
Just replace ExtObject3D by your types : InnerObjT1 |
When passing the
columns
argument inqx::dao::fetch_all
, if the "column" pertains to a class variable (separately registered), its inner variables are not filled.Illustration:
collection_1.h
collection_1.cpp
main.cpp
The result I get is:
As you see, the keys, "someStuff" inside "a", "b" and "c" were not filled in case projection was used, but were normally filled when it was not used.
The text was updated successfully, but these errors were encountered: