Categories
Mastering Development

Direct assignment to the forward side of a many-to-many set is prohibited. Use fieldname.set() instead

Custom User Model from django.db import models # from roles_tasks.models import mst_org_roles # from organizations.models import config_orgs # from projects.models import mst_projects from django.contrib.auth.models import AbstractBaseUser,BaseUserManager class UserManager(BaseUserManager): def create_user(self,email, first_name, last_name, role_id, org_id, project_id, status, created_by, modified_by, password=None, is_admin=False, is_staff=False): if not email: raise ValueError(“email id is required”) if not password: raise ValueError(“password must […]

Categories
Mastering Development

Build dynamic SQL query to sort records with limit

Please consider the below scenario to understand my requirement. I have list of the product types Webinar, Summit, Intent Story: There is an user(account) can have subscribed to any (Webinar, Intent, Summit) product types. If user subscribed to all above product_type then in response all product_type should be displayed by below given order but the […]

Categories
Mastering Development

How to declare enum in Angular 8 component I am getting error while declare enum in angular 8

import { Component,OnInit } from ‘@angular/core’; @Component({ selector: ‘app-root’, templateUrl: ‘./app.component.html’, styleUrls: [‘./app.component.css’] }) export class AppComponent { enum AppStatus { ACTIVE, INACTIVE, ONHOLD } } I am trying to use enum in component but gettting error unexpected token. A constructor, method, accessor, or property was expected.

Categories
Development

hibernate: why does session.update() produce OptimisticLockException?

I’m using hibernate and I wanted to update a record in my database. However, whenever I call this method, I get the famous OptimisticLockException. Why is this Exception thrown in my case? How to update a row in the database the correct way ? Note: I’m only firing this method one time. So, I assume […]

Categories
Development

MS SQL Server 2014 Stored Procedure Fails to Transfer a DateTime Field; all other data in row is transferred

I have a staging table where new courses are entered. Moderator looks at course, approves (Moderated = 1), and runs the stored procedure below that moves the whole row into a permanent table. It works fine and dandy but does not migrate one DateTime column over. It is the only DateTime column. I have tried […]

Categories
Development

Concartenate values of a property based on another property

I have this class public enum SubStatus { active, inactive, unset} public class SubItem { public SubStatus Status { get; set; } public string Value { get; set; } } And the values in the class could look like this List<SubItem> list = new List<SubItem>() { new SubItem() { Status = SubStatus.active, Value = “1” […]

Categories
Development

Active record lookup intermittently slow inspite of index being present on the column in where clause

I have a simple new API endpoint, which involves querying my newly setup and populated table – inventory_products. The schema of inventory_products table is : CREATE TABLE `inventory_products` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `inventory_product_id` binary(16) DEFAULT NULL, `product_id` binary(16) DEFAULT NULL, `status` enum(‘ACTIVE’,’INACTIVE’,’DELETED’) DEFAULT ‘ACTIVE’, `priority` int(11) DEFAULT ‘0’, `inventory_service_id` tinyint(3) DEFAULT NULL, […]

Categories
Development

allowNull:false and required:true did not validate null string input

My app is running nodejs 10.16 and sequelizejs 5.7 with postgresql 11. The initial connection is setup as: const Sql = require(“sequelize”); const db = new Sql(‘mydb’, ‘postgres’, `${process.env.DB_PASSWORD}`, { host: ‘localhost’, dialect: ‘postgres’, port:5432, } ); A Group model is defined as: const Joi = require(‘@hapi/joi’); const Sql = require(‘sequelize’); const db = require(“../startup/db”); […]

Categories
Development

inner join with aggregation pipelines

I have a set of documents with an array of sub-documents in MongoDB, cut down schemas below: Items: const itemSchema = new Schema({ name: { type: String, required: true }, status: { type: String, enum: [‘active’,’inactive’,’quarantine’,’deleted’] }, subitems: [{ type: Schema.ObjectId, ref: ‘subitem’ }] }); Sub Items: const subItemSchema = new Schema({ parent: { type: […]