Categories
Mastering Development

Jest testing without service connecting to DB

I am having issues with testing my nodejs app that has multiple connections to the DB. I would like to run my test without creating any connections to the DB. However, since the individual connections are required in my model, it seems to be connecting to the DB even though it is not needed. I […]

Categories
Mastering Development

Mongoose validation Error when seeting up relations

I am using mongoose and trying to setup relation between two schemas but I am getting ValidationError errors: { userId: ValidatorError: Path `userId` is required. at validate (C:\ShoppingApp\node_modules\mongoose\lib\schematype.js:1222:13) at C:\ShoppingApp\node_modules\mongoose\lib\schematype.js:1205:7 at Array.forEach (<anonymous>) at ObjectId.SchemaType.doValidate (C:\ShoppingApp\node_modules\mongoose\lib\schematype.js:1150:14) at C:\ShoppingApp\node_modules\mongoose\lib\document.js:2439:18 at processTicksAndRejections (internal/process/task_queues.js:79:11) at runNextTicks (internal/process/task_queues.js:66:3) at processImmediate (internal/timers.js:429:9) { properties: [Object], kind: ‘required’, path: ‘userId’, value: […]

Categories
CMS Mastering Development Wordpress

New field on checkout is shown but it’s not saved on the order details

I am having a problem adding a custom field on the checkout of WooCommerce, I am using this code: add_filter(‘woocommerce_checkout_fields’,’custom_override_checkout_fields’); function custom_override_checkout_fields($fields) { $fields[‘billing’][‘billing_colonia’] = array( ‘label’ => __(‘Colonia’, ‘woocommerce’), ‘placeholder’ => _x(”, ‘placeholder’, ‘woocommerce’), ‘required’ => true, ‘class’ => array(‘form-row-wide’), ‘clear’ => true ); $fields[‘shipping’][‘shipping_colonia’] = array( ‘label’ => __(‘Colonia’, ‘woocommerce’), ‘placeholder’ => _x(”, […]

Categories
Mastering Development

How to use full text search in referenced documents?

I know this was asked before, but I can’t find an answer that works for me. I have some documents, which have reference to another document, like users and orders: Users model: import mongoose from ‘../database/index.js’; import mongoosePaginate from ‘mongoose-paginate-v2’; const UsersSchema = new mongoose.Schema({ user_id: { type: String, required: true, }, email: { type: […]

Categories
Mastering Development

Can we update a normal field and a nested array field at the same time in MongoDB?

I have a product schema like quantity: { type: Number, required: true }, batch_no: { type: [ { batch_no: { type: String, required: true }, quantity: { type: Number, required: true }, created_at: { type: Date, default: Date.now() }, } ], default: [] } I am trying to update both the quantity fields in one […]

Categories
Mastering Development

How to validate the array of [‘uuid’,’uuid’] in loopback and also each UUID must be the reference to another model id?

I have a Loopback models that looks like this: Model A { Properties { "name": { "type": "string", "length": 255 }, "B_ids": [ "string" ] } } ——————————————————————————————————- Model B { Properties { "name": { "type": "string", "length": 255 }, "id": { "type": "string", "id": true, "required": true, "defaultFn": "uuidv4", "postgresql": { "dataType": "uuid" } […]

Categories
Mastering Development

How to insert/add array of nested objects into mongodb database using axios and react

I am working on a react application where i am trying to add an object with an array of nested objects using axios and react .The problem that i am facing is that when i add the data through postman , then the data gets added , but when i add through the react application […]

Categories
CMS Drupal Mastering Development

How to display the rendered entity of a store in a code?

I created a custom module for Drupal 8 and Drupal Commerce. It is used to display a link "Accept the conditions of sale" in the purchase funnel during an order. This link displays a modal window with the rendering of a page. I have created a "terms and conditions" display mode in my store types. […]

Categories
CMS Magento Mastering Development

Magento 2 add extra field for customer group create/edit form at the backend

I have added column at "customer_group" table and able to display the column customer group table at back-end , and fields for the added column is showing at edit form , but the value are not saved in the database Here is my code di.xml <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> Form.php <?php namespace Belvg\Customer_group_ext\Model\Plugin; use Magento\Customer\Api\GroupRepositoryInterface; use […]

Categories
CMS Drupal Mastering Development

Form API placeholder attribute rendered as “- Select -“

In a custom Drupal 8 module, I have a couple of Form API fields of ‘#type’ => ‘select’: <? $form[‘form-right’][‘field_role’] = [ ‘#type’ => ‘select’, ‘#title’ => $this->t(‘Role’), ‘#title_display’ => ‘invisible’, ‘#required’ => TRUE, ‘#options’ => [ ‘foo’ => $this->t(‘Role Foo’), ‘bar’ => $this->t(‘Role Bar’), ‘baz’ => $this->t(‘Role Baz’), ‘quux’ => $this->t(‘Role Quux’), ‘plugh’ => […]