Fix BooksController.createBookReference()
This commit is contained in:
parent
707c22dac7
commit
63c7d3676d
|
@ -105,10 +105,10 @@ class Inventaire {
|
|||
}
|
||||
});
|
||||
|
||||
const bookData = await json;
|
||||
let bookData = await json;
|
||||
|
||||
if (typeof bookData.entities !== 'undefined' && typeof bookData.entities[uri] !== 'undefined') {
|
||||
const bookData = Inventaire.handleEntity(bookData.entities[uri], this.lang);
|
||||
bookData = Inventaire.handleEntity(bookData.entities[uri], this.lang);
|
||||
bookData['covers'] = await this.getCovers(bookData.uri);
|
||||
|
||||
return bookData;
|
||||
|
|
|
@ -98,20 +98,18 @@ class BooksController {
|
|||
const inventaire = new Inventaire(this.language);
|
||||
const bookData = await inventaire.getBookData(uri);
|
||||
return await bookReferencesModel.create({
|
||||
values: {
|
||||
name: bookData.name,
|
||||
description: bookData.description,
|
||||
sources: {
|
||||
[source]: uri,
|
||||
},
|
||||
covers: bookData.covers.map(cover => {
|
||||
return {
|
||||
sourceId: uri,
|
||||
url: cover.url,
|
||||
};
|
||||
}),
|
||||
locale: this.language,
|
||||
}
|
||||
name: bookData.name,
|
||||
description: bookData.description,
|
||||
sources: {
|
||||
[source]: uri,
|
||||
},
|
||||
covers: (bookData.covers ? bookData.covers : []).map(cover => {
|
||||
return {
|
||||
sourceId: uri,
|
||||
url: cover.url,
|
||||
};
|
||||
}),
|
||||
locale: this.language,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ async function routes(fastify, options) {
|
|||
}
|
||||
|
||||
const books = new BooksController(request.body.source, request.body.uri, request.language);
|
||||
const newBookReference = await books.createBookReference(request.body.source, request.body.uri);
|
||||
const newBookReference = await books.createBookReference(fastify.models.BookReference, request.body.source, request.body.uri);
|
||||
console.log('created new bookreference', newBookReference);
|
||||
return newBookReference.id;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue