Results 1 to 8 of 8

Thread: Association ManyToMany CRUD with mySql relation keys table theory ?

  1. #1
    Sencha Premium User
    Join Date
    Jun 2018
    Posts
    24

    Red face Association ManyToMany CRUD with mySql relation keys table theory ?

    Hello all,

    I have to do a manyTomany association with crud ability via session.
    In my mySql database, I have 3 tables :
    - article (with id + other fields)
    - tag (with id + other fields)
    - articleTag (with idArticle and idTag)

    So I have to make 2 models with ajax proxy and api urls for crud
    But how can I specify the association which have to know the existence of my third table ? (relation table with id's of articles and tags) ?
    If I understood, in a manyTomany association, extjs use a "matrix" table which seems to be like my association table. How can I use it ?
    Is there a way to use it to "crud" changes through my 3 mysql tabs with one action ?
    what is the way/theory ?

    I hope you understood my poor English...
    Thank you


    Ok, No answer ?

    I declared my association in my Tag model as follow :

    Code:
    manyToMany: {
        ArticleTags: {
            type: 'Article',
            role: 'articles',
            field: 'idArticle',
            right: {
                field: 'idTag',
                role: 'tags'
            }
        }
    },
    So I think the matrix table should have for name : ArticleTags
    But I don't know where to put a proxy to specify crud api urls to request in my mysql relation table (similar to this Matrix table).

    when I load articles in a grid and I test in console :
    the record : I can see a session and an association so I think the declaration seems ok. NO ???
    When I test with : Ext.ComponentQuery.query('grid')[0].getStore().findRecord('id',111).tags() or Ext.ComponentQuery.query('grid')[0].getStore().findRecord('id',111).getAssociatedData() the console
    returns an empty tags array and it seems that there is no ajax call....

    Please, help...
    help...
    ...
    Last edited by Tangram; 13 Aug 2018 at 1:06 AM. Reason: I go on investigate but....

  2. #2
    Sencha Premium User
    Join Date
    Jun 2018
    Posts
    24

    Default

    Nobody ?
    Is my question absurd ???
    Please, tell me something....

  3. #3
    Sencha User dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,748
    Answers
    55

    Default

    Your question is not absurd just not a well documented area. As of v6.5.2 (though probably still true), manyToMany data is stored in the Ext.data.Session and is can be retrieved in the getChanges() API. There is no built-in way to save m2m data. The way it is queries is as if the matrix table is not present. In other words the filter uses the otherId from the matrix table as if it were present on the model.
    Don Griffin

    "Use the source, Luke!"

  4. #4
    Sencha Premium User
    Join Date
    Jun 2018
    Posts
    24

    Default

    oh yes, an answer ! ;o)
    Thank you for that, Don.

    But I don't really understand... "can be retrieved in the getChanges() API" ??? Isn'it only to get the changes made to records of the session ???
    "In other words the filter uses the otherId from the matrix table as if it were present on the model."... So ??? Forgive me but I don't see what you're trying to explain....

    As I didn't had any answer to this post, I opened a ticket where I was more descriptive.
    I'm still waiting for some answer. Maybe you could take a look on it ?

    Thank you.

  5. #5
    Sencha User
    Join Date
    Apr 2013
    Posts
    913
    Answers
    105

    Default

    Since Don no longer works for Sencha, I doubt that he can see your ticket.
    Anyway, have you looked at the example app he made called "Ticket App" (examples/classic/ticket-app)? Users and user groups have many-to-many relationship.

  6. #6
    Sencha Premium User
    Join Date
    Jun 2018
    Posts
    24

    Default

    Quote Originally Posted by hakimio View Post
    Since Don no longer works for Sencha, I doubt that he can see your ticket.
    Anyway, have you looked at the example app he made called "Ticket App" (examples/classic/ticket-app)? Users and user groups have many-to-many relationship.
    Thank you hakimio,
    I've just looked at it. But I can't see the sources ?

  7. #7
    Sencha User
    Join Date
    Apr 2013
    Posts
    913
    Answers
    105

    Default

    What do you mean? The source files are included with ExtJS distribution.

  8. #8
    Sencha Premium User
    Join Date
    Jun 2018
    Posts
    24

    Default

    Quote Originally Posted by hakimio View Post
    What do you mean? The source files are included with ExtJS distribution.
    Ah. Ok. I saw the exemple on the sencha's website ;o)

Similar Threads

  1. Association ManyToMany CRUD with mySql theory ?
    By Tangram in forum Ext JS 6.x Q&A
    Replies: 0
    Last Post: 3 Aug 2018, 4:02 AM
  2. [FIXED] Remove record from ManyToMany association
    By sksoft in forum Ext 5: Bugs
    Replies: 2
    Last Post: 24 Oct 2014, 9:41 AM
  3. Remove record from ManyToMany association
    By sksoft in forum Ext 5: Q&A
    Replies: 0
    Last Post: 16 Oct 2014, 12:22 PM
  4. manyToMany creates invalid association store
    By Artur Bodera (Joust) in forum Ext 5: Q&A
    Replies: 9
    Last Post: 5 Sep 2014, 1:05 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •