Commit 26e0a8eb authored by ns17's avatar ns17

create arquive model

parent f8264c64
'use strict';
const yaml = require('js-yaml');
const fs = require('fs');
var app = require('../../server/server');
module.exports = function(Arquivo) {
/**
* metodo para abrir o arquivo
* @param {string} nome
* @param {Function(Error, object)} callback
*/
Arquivo.open = async function(nome, callback) {
var arquivo_aberto;
console.log("nome",nome)
if (nome == "rooms"){
var arquivo = await app.models.Arquivo.findById("1")}
else if (nome == "schedules"){
var arquivo = await app.models.Arquivo.findById("2")}
try {
var fileContents = await fs.readFileSync(arquivo.caminho, 'utf8');
var arquivo_aberto = await yaml.load(fileContents);
return (arquivo_aberto);
} catch (e) {
console.log(e);
}
};
};
\ No newline at end of file
{
"name": "Arquivo",
"plural": "Arquivos",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"nome": {
"type": "string",
"required": true
},
"caminho": {
"type": "string",
"required": true
},
"data_modificacao": {
"type": "date"
},
"dados": {
"type": "object"
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {
"open": {
"accepts": [
{
"arg": "nome",
"type": "string",
"required": true,
"description": ""
}
],
"returns": [
{
"arg": "arquivo_aberto",
"type": "object",
"root": true,
"description": ""
}
],
"description": "metodo para abrir o arquivo",
"http": [
{
"path": "/open",
"verb": "post"
}
]
}
}
}
......@@ -123,5 +123,9 @@
"mail_dinf": {
"dataSource": "Email_d",
"public": true
},
"Arquivo": {
"dataSource": "db",
"public": true
}
}
......@@ -29,7 +29,7 @@ function getScheduleInstance(h, cb){
course: horarioCurso,
department: "dinf",
klass_id: 1,
assigned: horario.salaCode
assigned: h.salaCode
});
cb(null,schedule);
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment