Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8928447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:26:20+00:00 2026-06-15T08:26:20+00:00

I have the following UseCase: A creates a Chat and invites B and C

  • 0

I have the following UseCase:

A creates a Chat and invites B and C – On the Server A creates a
File. A, B and C writes messages into this file. A, B and C read this
file.

I want a to create a file on server and observe this file if anybody else writes something into this file send the new content back with websockets.

So, any change of this file should be observed by my node.js application.

How can I observe files-changes? Is this possible with node js without locking the files?

If not possible with files, would it be possible with database object (NoSQL)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:26:21+00:00Added an answer on June 15, 2026 at 8:26 am

    Good news is that you can observe filechanges with Node’s API.

    This however doesn’t give you access to the contents that has been written into the file.
    You can maybe use the fs.appendFile(); function so that when something is being written into the file you emit an event to something else that "logs" your new data that is being written.

    fs.watch(): Directly pasted from the docs

    fs.watch('somedir', function (event, filename) {
        console.log('event is: ' + event);
        if (filename) {
            console.log('filename provided: ' + filename);
        } else {
            console.log('filename not provided');
        }
    });
    

    Read here about the fs.watch(); function

    EDIT: You can use the function

    fs.watchFile(); 
    

    Read here about the fs.watchFile(); function

    This will allow you to watch a file for changes. Ie. whenever it is accessed by some other processes of any kind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following use case, my file contents look like this a b
I have a following usecase. A process serializes certain objects to a file using
I have the following code in my Simulacion controller: [Authorize] public ActionResult Create() {
I have the following usecase: A div with some buttons When the user clicks
I have a usecase where I want to set the value of a field
I have a huge application running in glassfish server which creates lot of short-living
I am facing the following problem. I have an image Gallery and I want
I have following use-case: there are several assemblies decorated with ProtoContract classes and I
I have the following use case: There's a class called Template and with that
I have following plist: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.