Categories
Mastering Development

How to find and update nested objects [closed]

Given the nested objects below, how do I find each ‘female’ and update their salary by 10%? var topSalary = { ‘Alex’ : {salary: 2000, gender: ‘male’}, ‘John’ : {salary: 1440, gender: ‘male’}, ‘Sarra’ : {salary: 5187, gender: ‘female’}, ‘Philip’ : {salary: 3309, gender: ‘male’}, ‘Anna’ : {salary: 2304, gender: ‘female’}, };

Categories
Mastering Development

mongoose aggregate $match does not match

I have an array of objects in which each object contains one array of action objects and one child object. I’d like to sum action points from one specific child id object. When I test the sum at mongoplaygroundhttps://mongoplayground.net/ it works as expected but in the code, it is not so good. Please, someone, help […]

Categories
Development

edgesData.forEach is not a function in Angular

import { Component, AfterViewInit, ElementRef, ViewChild } from ‘@angular/core’; import { Network, DataSet, DataView} from ‘vis’; @Component({ selector: ‘app-test’, templateUrl: ‘./test.component.html’, styleUrls: [‘./test.component.scss’] }) export class TestComponent implements AfterViewInit { @ViewChild(‘network’, {static: false}) el: ElementRef; @ViewChild(‘nodeFilterSelect’, {static:false}) nodeFilter: ElementRef; @ViewChild(‘edgesFilter’, {static: false}) edgeFilter: ElementRef; private networkInstance: any; startNetwork(data){ const container = this.el.nativeElement; this.networkInstance = new […]

Categories
Development

How to post data in angular

This is the angular code i used to post data const postData = { “username”: “Customer004”, “email”: “customer004@email.com”, “password”: “0000252525”, “gender”: “male”, } this.http.post(“http://localhost/android/Api.php?apicall=signup”, postData, options) .subscribe(data => { console.log(data); }); But when i tried to print the response i am getting null in the backend using php code response[‘post’]=$_POST[‘username’]; it is giving me null […]

Categories
Development

How to save data into new rows in Spring Data JPA?

I have a JSON like this. { “productName”:”soap”, “pQty”:10, “price” : 100, “customerList”:[ { “name”:”dasun”, “email”:”lakmal@gmail.com”, “gender”:”male” }, { “name”:”BM”, “email”:”BM@gmail.com”, “gender”:”male” } ] } I want to save this data into two separet tables called Product and Customer which having 1 to many relationship same as JSON`s appears. I tried to save data using […]

Categories
Development

Error displaying data from retrofit: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

I am trying to get data to my app using retrofit, the data is being logged, it however doesn’t display. I keep getting this error Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ Not sure what am doing wrong. The response looks something similar to this { info: { count: 493, […]

Categories
Development

is it possible to create an Object in javascript from looping data in array? [duplicate]

This question already has an answer here: “Variable” variables in Javascript? 7 answers just like the title said. i want to create a new object from data inside array below: the name of the object is the first and last name. //this is the input arrayToObject([[‘Christ’, ‘Evans’, ‘Male’], [‘Robert’, ‘Downey’, ‘Male’]]); //this is output that […]

Categories
Development

How to make a sub-dictionary from data of a line of a txt file?

I have this .txt file that needs to transformed into a dictorionary: (the order of the lines may vary) name : john doe age : 23 gender : MALE address : kendall 6, Miami career: mechanical engineer times going : 2 number of assignments : 4 semester : 4 average : 9.2 interests : gaming, […]

Categories
Development

GraphQL update and delete mutations not working

I’m new to GraphQL and working on AWS AppSync and testing with POSTMAN I created API and able to run createMutation and List query Here is my schema input CreateUserInput { id: ID! name: String! gender: String! email: String! password: String! } input DeleteUserInput { id: ID! name: String! } type Mutation { createUser(input: CreateUserInput!): […]

Categories
Development React

Update existing item or add new item to reducer | React-Redux

I have a requirement where I’ll receive an array of objects. I’ve to check if the received array of objects already present in the store. If yes then I want to update the new object with old object, else I want to add the new element to the store. const initialState = { …. …. […]