Relacja jeden do wielu w CompoundJS

Jestem nowym użytkownikiem CompoundJS i miałem problem z skonfigurowaniem jednego do wielu relacji z jugglingDB.I używam MySQL jako bazy danych.

Założyłem dwa modele książki i autora.

Książka ma wielu autorów.

To jest mójschema.js (db / schema.js):

var Book = describe('Book', function () {
    property('title', String);
    property('isbn', String);
    property('authorId', Number);
    set('restPath', pathTo.books);
});

var Author = describe('Author', function () {
    property('name', String);
    property('authorId', Number);
    set('restPath', pathTo.authors);
});

Umieściłem relację w modelach / Book.js. To jest mójBook.js (modele / Book.js):

module.exports = function (compound, Book) {
  Book.hasMany(compound.models.Author,   {as: 'author',  foreignKey: 'authorId'});
};

To jest mójAuthor.js (modele / Author.js):

module.exports = function (compound, Author) {
 Author.belongsTo(compound.models.Book, {as: 'books', foreignKey: 'authorId'});
};

Problem polega na tym, że nie mogę stworzyć tych relacji. Kiedy sprawdzam tabelę, nie ma w tabeli klucza obcego.

Usuwam relację z modeli Book.js i Author.js i umieszczam relację w samym schema.js

Potem schema.js wyglądają tak:

var Book = describe('Book', function () {
    property('title', String);
    property('isbn', String);
    property('authorId', Number);
    set('restPath', pathTo.books);
});

var Author = describe('Author', function () {
    property('name', String);
    property('authorId', Number);
    set('restPath', pathTo.authors);
});

Book.hasMany(Author, {as: 'author',  foreignKey: 'authorId'});
Author.belongsTo(Book, {as: 'books', foreignKey: 'authorId'});

ale wynik jest taki sam.

Czy jest problem w powyższym kodzie? jeśli tak, jak mogę to rozwiązać?

questionAnswers(1)

yourAnswerToTheQuestion