4975-mdbVersion-last-method #1245
|
@ -247,7 +247,8 @@
|
||||||
"Empty data source": "Origen de datos vacio",
|
"Empty data source": "Origen de datos vacio",
|
||||||
"Email verify": "Correo de verificación",
|
"Email verify": "Correo de verificación",
|
||||||
"Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment",
|
"Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment",
|
||||||
"Receipt's bank was not found": "No se encontró el banco del recibo",
|
"Receipt's bank was not found": "No se encontró el banco del recibo",
|
||||||
"This receipt was not compensated": "Este recibo no ha sido compensado",
|
"This receipt was not compensated": "Este recibo no ha sido compensado",
|
||||||
"Client's email was not found": "No se encontró el email del cliente"
|
"Client's email was not found": "No se encontró el email del cliente",
|
||||||
}
|
"Not exist this app name": "No existe este nombre de aplicación"
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('last', {
|
||||||
|
|||||||
|
description: 'Upload and attach a access file',
|
||||||
joan
commented
Cambiar la descripción Cambiar la descripción
|
|||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'appName',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: 'The app name'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: ['object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:appName/last`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.last = async(ctx, appName) => {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const versions = await models.MdbVersion.find({
|
||||||
|
where: {app: appName}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!versions.length)
|
||||||
|
throw new UserError('Not exist this app name');
|
||||||
|
|
||||||
|
let maxNumber = 0;
|
||||||
|
for (let mdb of versions) {
|
||||||
|
if (mdb.version > maxNumber)
|
||||||
|
maxNumber = mdb.version;
|
||||||
|
}
|
||||||
|
return maxNumber;
|
||||||
|
};
|
||||||
|
};
|
|
@ -11,14 +11,12 @@ module.exports = Self => {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The app name'
|
description: 'The app name'
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
arg: 'newVersion',
|
arg: 'newVersion',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
required: true,
|
required: true,
|
||||||
description: `The new version number`
|
description: `The new version number`
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
arg: 'branch',
|
arg: 'branch',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/mdbVersion/upload')(Self);
|
require('../methods/mdbVersion/upload')(Self);
|
||||||
|
require('../methods/mdbVersion/last')(Self);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Si este método devuelve la última versión, quizás sería mejor nombrarlo last-version?
Como está dentro de mdbVersion, ¿ya se intuye que obtienes la última version no?
Sabiendo esto, ¿hago el cambio de nombre de last → last-version?
Ahora que lo comentas, si tiene sentido.