Max Thieme
Posts: 0
Joined: Wed Apr 23, 2014 7:27 pm

The best Way to Reference two Collections in One database?

Hello together,

after hours of reading or trying, i leave the path of sureness if my way is the correct way. Now i thought, ask the experts and listen to what they recommend.(Sorry about the english grammatics...by the way).

Like the Topic says: I want to reference a Collection to another Collection.
My Issue is i dont know which way is the bettest and i dont know how to do it. Is it possible that you give me some impuls so that i get on the right way? I think there is no right way or truth or like bla bla, thats the interesting thing on programming... :)

Codelines i've tried:

//2 Collections in my DB(DBNAME = "realife20"
// testcollection with field "testid"
//childcollection with field "childid", "sento", "sentfrom", "text"

realife20.test.insert ( { //databasename.collection.insert

"testid": 12345,
"childid": "1",
"sento": "torreto",
"sentfrom": "sam",
"text": "funktioniert die referenzierung?"

}
)
;
I know that this code has no refer string or something like that. does the commands $ref, $db, $id work in appery.io? As i tryd i got no results...

like you can see, there are fixed values in the code. The reason for this is, i want to try, if this sort of code works over the "Run Javascript"-Action in the Event's. Nothing happens, but it can also be the code.

I look forward to your answers and appreciate :)

Greets from Germany

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

The best Way to Reference two Collections in One database?

Hi Max,

Please tell us in more details what result is expected? How do you want to use them?
Are these collections from the same DB?

Max Thieme
Posts: 0
Joined: Wed Apr 23, 2014 7:27 pm

The best Way to Reference two Collections in One database?

Hi Alena,

i want them to use in one way.
The structure i thought about was:
Database

  • Collection 1 (Where the parents stored)

  • Collection 2 (some fields with a reference to the parents over an id)

  • the idea is to create a document for one user and his "useractivitys" with an id again (docid or something like that) and store every user action in this "useractivity" document. This useractivity document has to refered to the collection1.
    Yes the Collections are in the same database and are the only collections in the database.

    One thing i think i now myself know is that the code ive posted above, is not useful because i didnt have a connection for the db access initialied. can it be something like that?

    Thanks for your response Alena.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

The best Way to Reference two Collections in One database?

There is a pointer field type.

Please read more about this type here: http://docs.appery.io/documentation/b...

Also there is some peculiarities in "where" clause for Query service.

So, if you have some questions about this please don't hesitate to ask.

Max Thieme
Posts: 0
Joined: Wed Apr 23, 2014 7:27 pm

The best Way to Reference two Collections in One database?

Thank you for your help. Appreciate :)

Return to “Issues”