update data by id in mongoose

try { let users = await User.updateOne({ _id: req.params.id }).set({ email: ‘hhihhhjih@drtgt’ }); return res.status(200).json( { success: true, data: users } ); } catch (error) { return res.status(400).json( { success: false, message: error.message } ); }

What is the “__v” field in Mongoose – remove that field

 const mongoose = require(‘mongoose’); const userSchema = new mongoose.Schema({ username: { type: String, // required: true, // unique: true }, email: { type: String, // required: true, // unique: true }, password: { type: String, }, firstname: { type: String, }, lastname: { type: String, }, address: { type: String, }, mobile: { type: String, …

What is the “__v” field in Mongoose – remove that field Read More »

How to install Laravel globally in Ubuntu

 =================================================================== Open your terminal using Ctrl+Alt+T and type the following commands Step 1: Install Laravel composer global require “laravel/installer” Step 2: Add composer to path to access laravel globally export PATH=”~/.config/composer/vendor/bin:$PATH” Step 3: Create a new Laravel application laravel new blog Step 4: Install missing packages and their dependencies cd blogcomposer install Step 5: Test the application …

How to install Laravel globally in Ubuntu Read More »

How to set defer or async attributes on enqueued script tags in WordPress

  <?php add_action( ‘wp_enqueue_scripts’, function () { wp_register_script( ‘my-script’, get_stylesheet_directory_uri() . ‘/assets/js/my-script.js’ ); wp_enqueue_script( ‘my-script’ ); } ); add_filter( ‘script_loader_tag’, function ( $tag, $handle ) { if ( ‘my-script’ !== $handle ) { return $tag; } return str_replace( ‘ src’, ‘ defer src’, $tag ); // defer the script //return str_replace( ‘ src’, ‘ async …

How to set defer or async attributes on enqueued script tags in WordPress Read More »