Page 1 of 1

The best Way to Reference two Collections in One database?

Posted: Tue Apr 29, 2014 9:35 pm
by Max Thieme

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


The best Way to Reference two Collections in One database?

Posted: Tue Apr 29, 2014 10:09 pm
by Alena Prykhodko

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?


The best Way to Reference two Collections in One database?

Posted: Tue Apr 29, 2014 10:20 pm
by Max Thieme

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.


The best Way to Reference two Collections in One database?

Posted: Tue Apr 29, 2014 10:43 pm
by Alena Prykhodko

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.


The best Way to Reference two Collections in One database?

Posted: Fri May 02, 2014 6:27 pm
by Max Thieme

Thank you for your help. Appreciate :)