#1 2019-11-27 20:13:41

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

Variant Fields Discussion

I wonder if there is any way to query an aggregate through a value from a variant field that contains json objects at the ORM level?


In the case I need to search the record by searching by phone number according to the example below.

 {
    "_id": {
        "$numberInt": "1"
    },
    "Name": "TRAGUETTA MOTTI",
    "Doc": "075017030000113",
    "Telephone": [
        {
            "Number": "4430345675"
        },
        {
            "Number": "443034554445"
        }
    ]
} 

Offline

#2 2019-11-27 21:40:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Variant Fields Discussion

If you use SQLite3 as backend, there are built-in JSON functions.

Offline

#3 2019-11-28 12:48:45

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

Re: Variant Fields Discussion

Thank you Ab for your answer. If I understood what you meant I could only do by opting for SQlite3? I'm currently using Mongodb, and I can do this query using specific MongoDb classes, but I wish I didn't have to opt for one and the other and that I could resolve the query at Mormot level. It's possible? or will I need to choose? I take very much into account what you said in a post "That changing databases by changing only one parameter is priceless"

Offline

#4 2019-11-28 16:35:19

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Variant Fields Discussion

Did you try with a where clause like 'Telephone.Number=?',[aNumber] over the latest revision of the framework?

I tried to add sub-field support last week.

Offline

#5 2019-11-28 18:11:34

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

Re: Variant Fields Discussion

Very good Ab, that's what I needed, I love this framework. It worked well even with use of like. Thanks for the answers.

Offline

#6 2019-11-28 22:02:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Variant Fields Discussion

smile

Offline

Board footer

Powered by FluxBB