javascript – Sending data via ajax generating a new "_id" in MongoDB

I send information to the Node backend via ajax to update a document in MongoDB, but each time I send the form via frontend, it generates a new "_id" instead of retrieving it. an existing one like I'm trying to do. Follows the code:

** NOTE: ** I tested on Insomnia (similar to Postman), and it has worked so far.

Front extract where I send form data

document.querySelector('#update').addEventListener(
    'click', 
    (
        ev, 
        url = '/admin/user/update', 
        data = {
            _id: userId, 
            email: document.querySelector('#email').value, 
            name: document.querySelector('#name').value, 
            userType: document.querySelector('#userType').value
        }, 
        success 
    ) => {

    success = (data) => {console.log(data)};
    console.log('===> response id', userId)
    let params = typeof data == 'string' ? data : Object.keys(data).map(
            function(k){ return `${k}:${data(k)}` }
        ).join(',');


    let xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");

    console.log('url =====> ', url);
    xhr.open('put', url, true);
    xhr.onreadystatechange = function() {
        if (xhr.readyState>3 && xhr.status==200) { success(xhr.responseText); }
    };
    xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

    let obj = new Object();

    params.split(',').forEach(element => {

        element = element.split(':')

        var name = element(0)
        var value = element(1)

        obj(name) = value

    });
    //console.log(obj)
    obj = JSON.stringify(obj);
    console.log('===>obj', obj)
    console.log('===>obj', obj.toString())

    xhr.send(obj);
    return xhr;
});

Background snippet handling this call

router.put('/user/update', async (req, res) => {

    let { _id, email, name, userType} = req.body;

    console.log('user/id =============>',  ObjectID(_id)); 
    
    console.log('req.body ======> ', req.body);

    try { 
        const user = await User.findOne(ObjectID(_id));
        console.log('User id ======> ', user._id);
        
        if( user ){
 
            console.log('User ======> ', user)

            console.log('email, name, userType =====> ', email, name, userType)

            console.log('ObjectID(user._id) ======> ', ObjectID(user._id))

            let updateUser = await User.updateOne({_id}, {$set:{ email, name, userType }});
            if(updateUser)  {
                console.log('===> updated', updateUser);
                console.log('User 2 ======> ', user)
                let message = "Usuario Editado com sucesso";
                console.log(message) 
    
                return res
                    .status(400)
                    .render(path.resolve('../frontend/views/layouts/admin/cadastroUsuario'), {message});
    
            }

            // if(update){
                
            //     let message = "Usuario Editado com sucesso";

            //     return res
            //         .status(400)
            //         .render(path.resolve('../frontend/views/layouts/admin/cadastroUsuario'), {message});
            // }

        }
        
    } catch (err){

        return res.status(400).send({error: 'Update failed: ' + err });
    }
});

Example of frontal return:

user/id =======> 5df4932bfc08782574c9cf56
req.body => {'{"_id":"5de9cc215f40d1626cabe9c9"
   ,"email":"dev@teste.com","name":"Vitor 
   TE22STE","userType":"adminNv2"}': ''
 }

pseudo-random generators – Generating pseudo-random floating-point numbers on a DSP floating-point vector

I'm working on a custom IEEE754 floating-point vector signal processor with 64 cores and I need to generate high-speed pseudo-random floating point numbers. The only numerical operation at my disposal is a floating-point multi-addition at the vector scale. So I can not use one of the conventional algorithms based on feedback shift registers, linear congruential operations, and so on.

The only approach I've found that architecture maps is an iterated chaotic logistic map and related variants, but I do not like these because they inevitably converge to a stable fixed point . However, they have the advantage of returning 64 pseudo-random numbers for each clock cycle. Can any one suggest suggestions for a better algorithm suitable for architecture?

architecture – Solutions for generating signed versions for IOS and Android

I have developed a small game engine and successfully generated xcode and android studio project files on a Windows machine. Now, I want to allow the user to generate a signed build in the cloud and publish them. Is there a way to do it?

On top of that, what I want is to have a github like cloud service + build build facility.

Thank you.

combinatorial – Find the difference equation solution by using generating functions

Find the solution of the difference equation $ y_ {k + 2} – 5y_ {k + 1} + 6y_ {k} = 2 $ with $ y_ {0} = $ 1 and $ y_ {1} = $ 2 using generating functions.

My attempt:

First, you have to find
$$ Y (s) = sum_ {k geq 0} y_ {k} s ^ {k} $$

So, we have this

$$ sum_ {k geq 0} y_ {k + 2} s ^ {k} – 5 sum_ {k geq 0} y_ {k + 1} s ^ {k} + 6 sum_ {k geq 0} y_ {k} s ^ {k} = 2 sum_ {k geq 0} s ^ {k} $$

$$ Rightarrow frac {Y (s) – 1 – 2s} {s ^ {2}} + 5 left ( frac {Y (s) – 1} {s} right) + 6Y (s) = frac {2} {1-s} $$

Now we can isolate $ Y (s) $. However, I would need to expand $ Y (s) $ in the power series, but I have problems. Someone can help me? Thank you in advance.

pr.probability – Is there a real function that satisfies the basic conditions of a moment generating function?

We all know that a mgf of a random variable $ m_X (t) $ is positive and $ m (0) = $ 1. My question is: if a real positive function $ f (t) $ satisfied $ f (0) = $ 1 and the function is pretty smooth (around 0), is there still a random variable $ X $ whose mgf is $ f (t) $? Or are there other conditions to fulfill?

The origin of this problem is that I want to build two independent random variables, $ X_1 $ and $ X_2 $, or $ X_1 $ follows a uniform distribution between $ (0, k) $, or $ 0 <k <$ 1 and $ X_1 + X_2 $ follows a uniform distribution between $ (0.1) $.$ X_2 $ apparently exists if $ 1 / k is a positive integer but if k $ is a real number?

dnd 5e – How can I run a realistic game in an open world with big differences of power, without generating constant TPK?

My own 5th campaign world is "without constraint", as you say, but the players are rarely overwhelmed by the head, and certainly not to the point of becoming TPK. High level dangers can to exist in the world, but if and how adventurers are exposed to it is a different question:

Boss monsters are busy

Monsters and high-level NPCs usually have more to do than repel low-level adventurers. That's why they have henchmen. Mr. Big only enters the game when the help is not removed, which means that the party is powerful enough to support it.

You must be that tall to ride

Adventurers of a given level tend to face challenges of an appropriate level because of their reputation. The owner of a copper mine might well hire a group of first- or second-level notables to hunt a gang of goblins that interferes with his operation, but an archmage who wants an arcane tome of an adult blue dragon's hunt heroes (or thugs) whose reputation indicates that they might be up to it.

You can judge a PC by its enemies

As they become more successful, the player characters naturally tend to progressively become powerful enemies. Adventurers who thwart an abduction perpetrated by a Yuan-Ti pureblood couple will most likely become the target of a stroke carried by local snake worship. A dozen adults died later and the cult leader calls a torpedo. Things degenerate – but not faster than the party is gaining levels.

You knew that work was dangerous when you took it

There are certainly many dangers around the world, but those that can cause TPK should carry the warnings of the FDA. If a group of third-level adventurers is about to chase a werewolf with at least one magic or silver weapon among them, the uplifting tale of a hunter who swears that his arrows were on the mark while bouncing harmlessly on the skin of the beast should send them to the preliminary search for the right equipment for the job. If this is not the case, players will probably be more careful with their next characters.

Wanted beta commentators and testers for the cPanel plug-in generating monthly revenue

First of all, I would like to thank some of the users of this forum who have answered some of my questions over the last few weeks and have … | Read the rest of https://www.webhostingtalk.com/showthread.php?t=1788102&goto=newpost

combinatorics – Using generating functions to find the number of compositions

Solve the following problem in three ways: a) as a principle of the inclusion-exclusion problem, b) using generating functions c) using the sums rule.
How many compositions of $ 2n + $ 1 with three parts have no part exceeding the sum of the other two? (We are therefore interested in compositions $ y_1 + y_2 + y_3 = 2n + 1 $ with $ y_i leq y_j + y_k $ does not matter when $ {i, j, k } = {1,2,3 } $).

So, I'm a little confused as to how to start any of these problems
For part a) I have the properties
$ p_1: y_1> y_2 + y_3 $
$ p_2: y_2> y_1 + y_3 $
$ p_3: y_3> y_1 + y_2 $
And we want $ e ( emptyset) = a ( emptyset) -a (p_1) -a (p_2) -a (p_3) $
Could someone help me get on the right track? Thank you!

massaction – Mass Delete and other mass actions on the inventory grid generating errors

We added additional features to a product inventory grid. From now on, the default actions that previously existed all fail with this error below. Note Products are selected with a check mark in the check box. So you do not know why it is said that you have to "choose something" Ideas that we have forgotten to do?

enter the description of the image here

1 exception (s):
Exception # 0 (Magento Framework Exception LocalizedException): An item must be selected. Select and try again.

Exception # 0 (Magento Framework Exception LocalizedException): An item must be selected. Select and try again.
# 1 Magento Catalog Controller Adminhtml Product MassStatus-> execute () called to (provider / magento / framework / Interception / Interceptor.php: 58)

Generating Certificates Using Advanced Electronic Signature (AdES)

For a mobile application, I would like to be as compliant as possible to the AdES standard.

The mobile application will perform transactions on behalf of the user, signing them first. A main service will verify the signature and proceed with the operations.

The main issue concerns restrictions on the identity of the certification authority.

Can a mobile device be its own certification authority or is it obligatory for another entity to issue the certificate?

In the first case, the mobile application would generate both certificates (CA and signature cert) when integrating the user. Both certificates would be sent to the server for later verification of the signature.

In the second case, the mobile application would generate a CSR and the backend would generate the signing certificate.

Are there any restrictions on how this process is allowed to work?