[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Node.js

139

Solutions

276

Contributors

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi all I am using the treeview click event , in order to get the current node with TreeView1.GetNodeAt
I need the mouse click x,y location
probelm is the treeview click event wont fire when I add code to the mouse down event.
what am i doing wrong ...
1
Prepare for an Exciting Career in Cybersecurity
Prepare for an Exciting Career in Cybersecurity

Help prevent cyber-threats and provide solutions to safeguard our global digital economy. Earn your MS in Cybersecurity. WGU’s MSCSIA degree program curriculum features two internationally recognized certifications from the EC-Council at no additional time or cost.

I am trying to set up an express website.

I am getting data from a database in date formats, ie :    2018-11-21T00:00:00.000Z,

My database just default the time to 0000Z, but the day should be 11/21/2018

Whenever I try to display the date,
even as a simple ejs write: <%=item.date %>
it's automatically converting it to my timezone MST, and I'm getting the date as
Tue Nov 20 2018 17:00:00 GMT-0700 (Mountain Standard Time)

How can I set up a standard across my app to keep it as the same day of the month ?
0
How get the last document inserted in mongoDB

Im using nodejs, express mongoose
0
Hi, I am unable to extract the mac id info from the attached picture

var obj = msg.payload;
var json = JSON.parse(obj);


var MAC = json[0][1].mac;

msg.payload = MAC;

return msg;

Open in new window


mac.png
0
Hello Experts,

Need to calculate the average of the row in Node.JS to be stored in the Average Data

So far I have attempted to do the following after the first row.week1 data-field

+(row.week1+row.week2+row.week3+row.week4)/4

I have removed this line in the code as it has caused the script to break.

Here is the code:
//Following is basic configuration for Node.JS
var express = require('express');
var app = express();
var mysql= require('mysql');
//Line 6 createsthe connection between the mysql database. 
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'root',
  password : '-------',
  database : 'databasetable'
});
//Getsthe information from either .html or node.js file. 
//Standard configuration
app.get('/', function (req,res) {
  connection.query('select * from storebenefit', function (error, results, fields){
    if (error) throw error;
	var reply='';
	//Object.keys() method returns an array of a given object's own property name
	//Callback to reply. access rows using index and columns using dot operator. 
	 reply+="<h2><table border='1'><tr>"
	 reply+="<td>No</td>"
	 reply+="<td>StoreName</td>"
	reply+="<td>Week1</td>"
	reply+="<td>Week2</td>"
	reply+="<td>Week3</td>"
	reply+="<td>Week4</td>"
	reply+="<td>Average</td></tr>"
	Object.keys(results).forEach(function(key){
		//For each loop passing results variable through the Object.Keys method.
		//Header of Table		
		var row= results[key];
		

Open in new window

0
Dear All
    i would like to know the loading mechanism of Ali's egg module, any advice? thanks
0
HI,

i am running a production application for night shift. Its start from 2000 hrs to 0800 hrs by defaults. Between this hours there are 4 breaks: -
2200 hrs ~ 2215 hrs
0005 hrs ~ 0035 hrs
0315 hrs ~ 0330 hrs
0530 hrs ~ 0550 hrs

This breaks are defaults setting where user can change the setting accordingly.

i have to calculate the production output only on production hours and system off automatically on breaks time. Base on default setting i am to determine my production hours as follows: -
 Break      start time ~ stop time ( i am comparing the current time between this running hours)
 1              2000 hrs  ~ 2200 hrs    (20:00:00 < current && current >22:00:00)
 2              2215 hrs  ~ 0005 hrs    (22:15:00 < current && current >00:00:00) || (00:00:00 < current && current >00:05:00)  
 3              0035 hrs  ~ 0315 hrs
 4              0330 hrs  ~ 0530 hrs
 5              0550 hrs  ~ 0800 hrs

I running in node red.

if (( current >= N_Prod_Start && current <= '23:59:59') || (current >= '00:00:00' && current <= N_Prod_Stop)){
    if ( current > N_Start[0] && current < N_Stop[0] ){
        for (i=0; i <= loop; i++){
            ST_cal(N_Start[0], current,cycle[i],0,i);
        }
    }
    else if (( current > N_Start[1] && current <= '23:59:59') || (current >= '00:00:00' && current < N_Stop[1] )){
        for (i=0; i < loop; i++){
            ST_cal(N_Start[1], current,N_cycle[i],N_sec[0],i);   
        } 
    }
    else if ( current 

Open in new window

0
Hi everyone
Can anyone help me or show me the right way to approach this assignment for my class? I am new to programming and missed lots of class. I just want to know the step by step process or the things I need to learn it.


Node-Express      Site      with      Nodemailer      – Research      Assignment
Using      a      brand      new      Express      Generator      App      skeleton,      add      the      following:
(1) Build      out      a      few      ‘standard’      routes (contact,      team,      etc.)      in      the      application;      
each      of      these      routes should      in      the      end      render      out      a      full      HTML-based      page
(from      included      partial files,      see      below),      but      you      do      not      need      any      content      
other      than      placeholder      text/image      content      in      each      view.
(2)Install      the      Nodemailer module      through      npm to      make      it      available locally,      
(using      SMTP) in      your      application.      Use      the      Nodemailer      documentation      as      a      
guide      and      build      a      route      and      a      view (form) to      enable      sending      an      email      through      
a      mail      service      (NOTE:      If      you      use      Gmail      you      may      get      a      warning      email      when      
you      test      it      that      your      Google      credentials      were      used      by      an      ‘unsafe’      app,      that      is      
to      be      expected). Search      for      Nodemailer      from      the      npm      main      site,      and      you      will      
get      to      the      documentation      that      will      show      you      how      to      set      everything      up.
(3) Use partials in      ejs,      the      page      renderer      you      are currently using,      so      that      you      can      
create      and      include      ‘proper’ views      (e.g.,      header,      footer).      Then      modify      all fullpage
ejs      examples into      a      more      modular      form.
(4) Add      some      CSS      styling to      the      ejs      template      views      in      your      application, again      not      
a      fully      designed      …
0
I have a Nutanix / Dell 3 node environment, I have managed to change the host Ip addresses to a new subnet and I have also change the CVM ip addresses, but I am having problems finding a way to either change the Cluster IP address from the CLI or break the cluster and rebuild with new IP and name.   Can anyone help?  I am not that conversant with Linux so a simple explanation if possible to get this done.

Many thanks

E.
0
I am trying to subtract time now() with data from mysql.
Over here, M_Start = "08:15:00"
Example Current = "22:02:39"
My intention is to get total seconds of the different.
While using moment function : error message : "ReferenceError: moment is not defined (line 22, col 9)"

var ST_Target;
var Shift_Target;

var M_Start = flow.get('Morning_start');
var M_Stop =flow.get('Morning_end');
var M_sec = flow.get('Morning_sec');

var M_cycle = flow.get("Cycle_Time");

var dt = new Date();
var hour = dt.getHours();
hour = ("0" + hour).slice(-2);

var minute = dt.getMinutes();
minute=("0" +minute).slice(-2);

var sec = dt.getSeconds();
sec=("0" + sec).slice(-2);

var current = hour+":" +minute+":"+sec;

var d = moment.duration(current.diff(M_Start[0]));

Open in new window

0
Problems using Powershell and Active Directory?
LVL 8
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

I'm trying to install PhoneGap CLI. When I run this
npm install -g phonegap@latest

Open in new window


I get this
phonegap CLI install error
I have reinstalled Node.js
The versions I have are
Node 10.11.0
npm 5.4.2 (installed when installing Node, I believe)

Can anybody help please?
0
2016 clustered environment . Nodes A crashed after a Ms path so it was rebuilt from an image of node B. I did make sure my ip's are correct.  Now im not able to Ping the private Network. Able to Ping one way only. Can ping from no B to node a. Cannot ping from node a two node be. This is after a crash where I had to rebuild node a from an image of node be. I have reset all settings but this one still has me confused any ideas.
Pings x.x.0.2 on nobe b to node a x.x.0.3 works.
Not working
Ping x.x.0.3  to x.x.0.2
Even isolated ping by typing.
Ping X.x.0.3 -S x.x.0.2
Still not pinging private network (heartbeat)
1
Hi,

In node red, while i insert the - timestamp datatype its work perfectly. while try to select data with the time stamp, its display different time.

Data insert in mariadb ----> 2018-09-19 23:47:26

While select data
if (Device > 0)
    msg.topic ="Select DeviceId, Line, outPIN, count,Time FROM mytab LIMIT 1";

return msg;

Open in new window


While try pull data out of mariadb the data timestamp show --> 2018-09-19 00:20:00
1
Hi I am selecting data from mysql database in node red: -

my database value are as follows:-
dbtime.png
Code in node red as follows: -
 msg.topic ="Select DeviceId, Line, outPIN, count,Time FROM mytab LIMIT 1"

Open in new window


In debug node i do get the time in different format and unable to store in different location of database.

9/17/2018, 4:59:29 PMnode: 4f250b1.97196f4
INSERT INTO mytable1 (DeviceId,Line,outPIN,count,Time) VALUES (?,?,?,?,?) : msg.payload : array[5]
[ 2, 1, "7", 1, "2018-09-16T13:28:24.000Z" ]
9/17/2018, 4:59:29 PMnode: d00874f1.76f388
msg : error
"Error: ER_TRUNCATED_WRONG_VALUE: Incorrect datetime value: '2018-09-16T13:28:24.000Z' for column 'Time' at row 1"

Open in new window



How i can format the time back to normal 'yyyy-mm-dd hh:mm:ss'
0
Hi,

I wanted to develop print solution for my web app : Web app to Desktop print appl using microsoft stack.

when someone press print button on web app, web app may send something like push notification as COMMAND to desktop application (User specific) and upon receipt of command Desktop print app can print the documents. If case of failure Desktop Print Application can send back information to web app about print failure.

To send push notification from web app to Desktop app,
can i use SignalR for sending user specific push notification ?

Please suggest :

1.Am i going in right direction.Whether the industry standards use same process like Google Print or PrintNode.

If not what technology/Process i can use for such application.
Initialy developing for one customer but need for multiple users.

regards,
0
Error message:  Node 'server' failed to form a cluster. This was because the witness was not accessible. Please ensure that the witness resource is online and available.

The virtual server is up and running and doesn't seem to have any problems but it will not become a part of the cluster.   The server node shows as being down and both the ISCSI connection and Public connections are down
0
Windows Cluster 2016 error , Node 1 unavailable after a restart (after installing Patch 1 for SQL cluster.) Pinged the IP and the IP is available , able to RDP to the server. Also all disk are up and running only issue is with NODE1 network its showing unavailable.
Please Advise.
0
Hello expert,

In UML (Unified Modeling Language) Activity Diagrams there are elements called fork
and join nodes. They are simply a black lozenge shapes  (see attached GIF) where several
parallel process merge (join) or split (fork).
This makes it necessary to have several arrows point to the fork or join node.
The node is created with a rounded rectangle.

The problem is the arrows only want to point to the rounded rectangle at the vertical and
horizontal mid points of the rounded rectangle. But the process arrows coming into the
join or fork could be a half dozen on each side.

Is there a way to make the fork or join node look like a comb on each side?
Join_node.jpg
0
I know there's a ton of questions around date/time storage and formatting, but I'm struggling to get the right approach. My app is a Node.js app with Express using mongoose with a MongoDB backend. I'm using moment.js to format my date/times.

The schema in question looks like:

const stateSchema = new mongoose.Schema({
  changed: {
    type: Date,
    default: new Date()
  }
});

Open in new window

Based on the docs, I was expecting the date to be stored in UTC by default, but instead I see this:
changed: 2018-08-15 17:26:14.499

Open in new window

I'm displaying the date/time with something like (pug):

p= `Changed: ${moment(state.changed).format('MMMM Do YYYY, h:mm:ss a')}`

Open in new window

On localhost, the app shows "August 15th 2018, 5:26:14 pm" but on the hosted Heroku app I get "August 15th 2018, 10:26:14 pm." I am expecting "August 15th 2018, 5:26:14 pm" because I'm opening the Heroku app in the same timezone, but it looks like it's giving me the server timezone.

What should I do to make sure the date/time shows up in the client's local timezone?
0
Become a Leader in Data Analytics
Become a Leader in Data Analytics

Gain the power to turn raw data into better business decisions and outcomes in your industry. Transform your career future by earning your MS in Data Analytics. WGU’s MSDA program curriculum features IT certifications from Oracle and SAS.  

I have a Button within a react component that has five values tied to the "Survey" component state.  Within the button I have a property called "triggerSurveyUpdate" that when the user clicks the button it triggers the property in parent component App so that I can change conditional rendering with the App component.  Also when the user clicks the button I want to call a function "handleClick" which in turn calls a function named "surveysIn". "surveyIn" in turn then does an axios post to post  my values from the 'Survey' component to my Node back end. The problem is that if I put both "this.props.triggerSurveyUpdate" and "this.handleClick.bind(this)" within the Button tag then the first "this.props.triggerSurveyUpdate" gets called but then "this.handleClick.bind(this) does not fire.  If I put both "this.props.triggerSurveyUpdate and "this.handleClick.bind(this)" within the handleClick(e) function then the "this.props.triggerSurveyUpdate" does not fire.  How can do I get react to fire both "this.props.triggerSurveyUpdate and "surveysIn" such that I am able to post values from the "Survey" component state to my back end and then also trigger the property "this.props.triggerSurveyUpdate" so that I can do my conditional rendering in my "App" component.  Below is my code for my Survey component.

import React, { Component } from 'react';
import {Slider} from 'primereact/components/slider/Slider';
import {Button} from 'primereact/components/button/Button';
import surveysIn 

Open in new window

0
HEllo,

I have an xml wihich i am try to extract data from.  It looks like this:

declare @xmlData xml = '
<BPSD-registret><Measurement2018>
<naza_bpsd><CarePlan>Hi</CarePlan>'+
  '<Actions>'+
    '<Current>'+
      '<Action>'+
        '<id>124</id>'+
        '<msr_id>405397</msr_id>'+
        '<activity>qdq</activity>'+
        '<when>d</when>'+
        '<where>qdw</where>'+
        '<how>dsf</how>'+
        '<whom>sdfsdf</whom>'+
        '<duration>sdfsdf</duration>'+
        '<estimations>'+
        '<estimation>2</estimation>'+
        '</estimations>'+
        '<measures/>'+
      '</Action>'+
      '<Action>'+
        '<id>125</id>'+
        '<msr_id>405397</msr_id>'+
        '<activity>Aaaa</activity>'+
        '<when>jklj</when>'+
        '<where>lk</where>'+
        '<how>jlk</how>'+
        '<whom>j</whom>'+
        '<duration>lkj</duration>'+
        '<estimations>'+
          '<estimation>1</estimation>'+
        '</estimations>'+
        '<measures>'+
          '<measure>1</measure>'+
          '<measure>2</measure>'+
          '<measure>3</measure>'+
        '</measures>'+
      '</Action>'+
    '</Current>'+
    '<Previous/>'+
  '</Actions>'+
'</naza_bpsd>'+
'</Measurement2018></BPSD-registret>' ;

Open in new window


I can extract and save the content of each <action> node using the following code:

insert into BPSD_MeasurementActions
select
a.value('(activity)[1]', 'nvarchar(500)' ) as act_Activity,
a.value('(when)[1]', 'nvarchar(500)' ) as act_When,
a.value('(where)[1]', 'nvarchar(500)' ) as act_Where,
a.value('(how)[1]', 'nvarchar(500)' ) as act_How,
a.value('(whom)[1]', 'nvarchar(500)' ) as act_With,
a.value('(duration)[1]', 'nvarchar(500)' ) as act_HowLong
from @xmlData.nodes('/BPSD-registret/Measurement2018/naza_bpsd/Actions/Current/Action') Actions(a)

Open in new window


The table BPSD_MeasurementActions has an identity column called Id (Integer).  

The problem is that the node <measures> has now been added to the xml.  I need to save the values of each <measure> node.   Therefore there is a one to many relationship with the <action> node and i need to save these values in a details table.  The value of Id from BPSD_MeasurementActions will be the foreign key.

Any sugestions on how i can traverse this xml and do the appropriate insertions?
0
Why use AngularJS instead of NodeJs

I would like to know why you should use AngularJS instead of NodeJS seeing that NodeJS can  fetch the Data from the Database server and present it to end user browser. I have seen some AngularJs videos where they use arrays and some code to present data on the browser, I have not seen any example where the Angular connect to the Database...
I thought probably NodeJs can do the same thing Angular does, with easier code.

Reading online, I see Angular is described as Framework ,whereas NodeJs is a Library...but do they achieve the same thing ?

Thank you
0
Hi

After researching heavily on why the delete query was failing in MS Access FE/SQl Server BE over the net and reading other IT books, it seems like the foreign key is cantered on the issues below:
INSERT and UPDATE Specification Category
I expanded the node to show information for the Delete Rule and the Update Rule for the relationship.
Delete Rule
It says specify what happens if a user tries to delete a row with data that is involved in a foreign key relationship:
•      No Action An error message tells the user that the deletion is not allowed and the DELETE is rolled back.
•      Cascade Deletes all rows containing data involved in the foreign key relationship. Do not specify CASCADE if the table will be included in a merge publication that uses logical records.
•      Set Null Sets the value to null if all foreign key columns for the table can accept null values.
•      Set Default Sets the value to the default value defined for the column if all foreign key columns for the table have defaults defined for them.
Update Rule
It says specify what occurs if a user tries to update a row with data that is involved in a foreign key relationship:
•      No Action An error message tells the user that the update is not allowed and the UPDATE is rolled back.
•      Cascade Updates all rows that contain data involved in the foreign key relationship. Do not specify CASCADE if the table will be included in a merge publication that uses logical records.
•      Set Null Sets the value to null if all …
0
Guys,

I need Help i am trying to add my failed Exchange Server 2010 to a DAG but when i ran the command in the image and getting the error. Please for your assistance.Adding-to-Cluster.JPG
0
i have a node that contains (america-germany) and  another node contain (america&#x02010;germany),when i check for this node are equals or not it say it is not Equal, i am using java with dom parser ,but when i put entity value(&#x02010;) in both node it say Equal,why can anyone help me
0

Node.js

139

Solutions

276

Contributors

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

Top Experts In
Node.js
<
Monthly
>