sql server – Peticion a SQL EXPRESS no funciona , retorna recordset vacio

Estoy creando un servidor con nodejs y sql express , la base de datos se conecta puedo leer tablas y todo bien , el problema esta cuando intento agregar un registro apoyandome con un stored procedure

PRODECURE:

CREATE PROCEDURE InsertOrder
    @Id INT ,
    @Title NVARCHAR(255) ,
    @Quantity INT ,
    @Message NVARCHAR(255) ,
    @City NVARCHAR(255) 

    AS BEGIN

    SELECT * FROM ORDERS WHERE
    (ID = @Id ) AND 
    (TITLE = @Title ) AND
    (QUANTITY = @Quantity ) AND
    (MESSAGE = @Message ) AND
    (CITY = @city ) 
    END 
    GO

Metodo para agregar una orden:

 async function addOrder(order) {

        try{
            let pool = await sql.connect(config);
            let insertProduct = await pool.request()
                .input("Id",sql.Int,order.Id)
                .input("Title",sql.NVarChar,order.Title)
                .input("Quantity",sql.Int,order.Quantity)
                .input("Message",sql.NVarChar,order.Message)
                .input("City",sql.NVarChar,order.City)
                .execute("InsertOrder");

                return insertProduct.recordsets;
                
        }
        catch(err){
            console.log(err);
        }
    }

METODO POST:

router.route('/orders').post((request,response) => {

    
    let order ={...request.body}


    dboperations.addOrder(order).then(result => {
        response.status(201).json(result);
    })
})

Al hacer un post desde postman me arroja un objeto vacio (()):

{
  recordsets: ( () ),
  recordset: (),
  output: {},
  rowsAffected: ( 0 ),
  returnValue: 0
}

No tengo idea de donde pueda estar mi error , entiendo que no esta procesándose con éxito la petición pero según yo los campos input y execute están bien, el proceso existe las variables también existen…, espero alguien me pueda ayudar, Gracias.

calculus – express $sech^{-1}(x)$ in terms of logarithms

I’m trying to express the following $sech^{-1}(x)$ in terms of logarithms, and would warmly appreciate feedback towards my approach. The solution should be :

$$ln(frac{1+sqrt{(1-x^2)}}{x})$$ when $x > 0$

However, I cannot seem to get this.

My working out:

$y = sech^{-1}(x); sech(y) = x$

$$-sech(y)tan(y) = x; $$

Once I got to here, I decided to transform the $sech$ and $tan$ into their hyperbolic identities.

$$-frac{sinh(y)}{cosh^2(y)}=frac{e^y-e^{-y}}{2}(frac{e^y+e^{-y}}{2})^2 = x$$

Though I’ve tried reworking this into a quadratic form $frac{b space pm space sqrt{b^2-4(a)(c)}}{acdot 2}$, however, I couldn’t manage to get the right form. I would greatly appreciate some help on the next steps towards this.

node.js – How to redirect page after using the DELETE method in express?

I’m a newbie in Nodejs and I’m coding a to-do app as a practical exercise. I’m having a problem that I cannot return to my index page “/” after using the DELETE method in Express. I use the deleteMany() of Mongoose to delete my docs, however after deleted all of those docs I couldn’t return to the “/” page, the system threw an error in the console:

DELETE http://localhost:3000/ 404 (Not Found)

although using res.redirect("/") is fine with POST method. I’ve found a guy with the same problem as mine on Stack Overflow, but his solutions are not working in my app. Another solution of him is using pure Javascript to redirect from the client, however I want to do this job in the severside.

app.delete("/delete/:item", function(req,res) {
    var item = req.params.item;
    //Using regex to change the url task to its original name
    var delTask = item.replace(/-/g," ");

    db.task.deleteMany({"name": delTask}, (err) => {
        if (err) throw err;
        console.log("Removal successful");
        
    })
    res.redirect("/");
})

express – Socket.io no funciona en nodejs

estoy haciendo un chat basico con logueo y register. pero tengo un problema y es que no se envian los mensajes, no me sale ningun error y llevo un buen rato intentado que funcione pero nada

codigo de socket.io del lado del servidor

    const socketIO = require('socket.io');
    const io = socketIO(server);

    io.on('connection', (socket) => {
        console.log(socket.id);

        io.on('chat:mensaje', function (data) {
             io.sockets.emit('chat:mensaje', data)
        })
    })

codigo del lado del cliente

    <div id="mensajes"> </div>
    <input type="text" id="chat">
    <button id="boton">enviar</button>

<script>
    const socket = io();

    output = document.getElementById('mensajes');
    button = document.getElementById('boton');
    input = document.getElementById('chat');

    button.addEventListener('click', () => {
        socket.emit('chat:mensaje', {
            mensaje: input.value
        });
    });

    socket.on('chat:mensaje', (data) => {
        output.innerHTML += '<div>' + data.mensaje + '</div>';
    })
</script>
<script src="/socket.io/socket.io.js"></script>

How to express the "*" denoting any text containing part of text when using IF function?

When using this formula
=if(AND('CASES LIST'!R4="No",P5="*neuro*"),"check","")

I am looking for the cell P5 if the text contains "neuro" in the text but it doesn’t work when I add star* before and after

discrete mathematics – Using Quantifiers to express “At Least Three”

I am having trouble interpreting this quantified statement:

All prime numbers at least three are even.

This is the pre-defined predicates given:

Square(x): x is a square number

Prime(x) : x is a prime number

Even(x) : x is an even number

This is what I thought of:

$$forall x in Z (Prime(n) implies exists x, y, z in Z (Prime(x) land Prime(y) land Prime(z) land Even(x) land Even(y) land Even(z)))$$

INCLUIR RECURSIVAMENTE CONTROLLERS EM NODE.JS E EXPRESS

Gostaria de saber como importar todos os controllers de um projeto node automaticamente.

abaixo deixo um código antigo que encontrei na internet que mostra como fazer

// routes/index.js
var fs = require('fs'),
    validFileTypes = ('js');

var requireFiles = function (directory, app) {
  fs.readdirSync(directory).forEach(function (fileName) {
    // Recurse if directory
    if(fs.lstatSync(directory + '/' + fileName).isDirectory()) {
      requireFiles(directory + '/' + fileName, app);
    } else {

      // Skip this file
      if(fileName === 'index.js' && directory === __dirname) return;

      // Skip unknown filetypes
      if(validFileTypes.indexOf(fileName.split('.').pop()) === -1) return;

      // Require the file.
      require(directory + '/' + fileName)(app);
    }
  })
}

module.exports = function (app) {
  requireFiles(__dirname, app);
}

esta versão funciona para rotas

usa – How do the Express Lanes in California know how many occupants a car using the express lane contains?

As it says in the table, to get the discount, you have to have a FasTrak Flex or CAV transponder. These transponders have a switch that you set to indicate the number of occupants. The express lane sensors detect the setting and charge you accordingly.

The sensors also apparently transmit this information to police in the area, presumably paired with your license plate or other information identifying your car. If the police see that the number of people in your vehicle does not match, you can be pulled over and given a ticket. The fine can be over $400.

air travel – Hidden-city ticketing with Lufthansa Express Rail

One thing to note is, that this is not Rail&Fly, but rather it’s named Express Rail.

The difference is, that with Rail&Fly you get a flexible train ticket to and from the airport, which is valid one day before departure as well as one day after arrival of your flight. Because of this flexibility, you are responsible to make it to the airport in time, i.e. you need to make sure, that you choose a connection which arrives early enough at the airport.

On the other hand, with Express Rail (which you have booked), you book a specific train under a Lufthansa flight number. In this case, it’s the same as you would have booked a connecting flight, which also means, that in case of train delay, Lufthansa will rebook you onto the next available flight (in your case it doesn’t matter, since the train segment is after the flight segment, but it’s important in the reverse case). In those trains, at least in the past, they have specific Lufthansa employees, which also have checked that passengers booked for that specific segment were on the train (i read those reports on FlyerTalk). If you have a return flight afterwards, you might get problems, if they check specifically on your train and if they actually sync back those information to the Lufthansa booking centers.
If you don’t have a return flight, then you will have no problems by leaving and not getting on the train in Frankfurt. For me personally, that would be the deciding factor. If i wouldn’t have a return flight, i would book the hidden city, if i would have, i would book it only to Frankfurt.

node.js – Problem with handlebars, express and mongodb

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.