Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var fs = require('fs');
- function Archivo() {
- this.guardar = function(data){
- nombre = Math.floor(Math.random() * (999-2)) + 2;
- var jsonData = JSON.stringify(data, null, " ");
- fs.writeFile("/tmp/json/" + nombre + ".json", jsonData, function(err) {
- if(err){
- console.log(err);
- }
- else{
- console.log('Se ha escrito correctamente');
- }
- });
- },
- this.leerArchivo = function(id){
- var fs = require('fs');
- fs.readFile("/tmp/json/" + id + '.json', 'utf8', function(err, data) {
- if(err){
- console.log(err)
- }
- else{
- console.log(data);
- return data;
- }
- });
- },
- this.LeerDirectorio = function(){
- }
- }
- module.exports = Archivo;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement