Skip to content

Commit

Permalink
CURD Operations
Browse files Browse the repository at this point in the history
  • Loading branch information
codingXpert committed Jun 26, 2022
1 parent 78188d3 commit fcb84e9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 0 additions & 1 deletion apple.txt

This file was deleted.

30 changes: 30 additions & 0 deletions curd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require('fs');
const path = require('path');
const dirPath = path.join(__dirname , 'curd');

const filePath = `${dirPath}/hello.txt`;

// Creating a file
fs.writeFileSync(filePath , 'this is a simple text');

// reading the file
fs.readFile(filePath , "utf8" , (err , item) => {
console.log(item);
})

// appending a file
fs.appendFile(filePath , ' and this an apple.txt file' , (err) => {
if(!err)
console.log('file is updated');
} );

//renaming the file
fs.rename(filePath , `${dirPath}/fruit.txt` , (err) => {
if(!err)
console.log('file name is updated')
});

// deleting the file

//fs.unlinkSync(`${dirPath}/fruit.txt`);

1 change: 1 addition & 0 deletions curd/fruit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is a simple text and this an apple.txt file

0 comments on commit fcb84e9

Please sign in to comment.