Parsing JSON responses and looking for specific variables - javascript

I need to parse through and look for a specific id. In the code below I need to be able to pull out the id number. It looks like this "itemIds":["918e337d-82ae-4e91-bdc3-16ad06572e21". I need to be able to pull the number "918e337d-82ae-4e91-bdc3-16ad06572e21". I have been having trouble understanding this concept. If you could send how or the actual code to do it . That would be very much appreciated.
{"dbSessionTokenMap":{"CXO_PC_ST":"e5b96399-fefc-4d9d-93ba-2aa1059008ce|{\"mtoken\":\"301:12#90271897#2=60818072#7=100439087\"}"},"id":"e5b96399-fefc-4d9d-93ba-2aa1059008ce","checkoutFlowType":"Guest","cartId":"ffd6cb2f-efc2-47b2-96d9-52d2cfb3d69b","items":[{"id":"918e337d-82ae-4e91-bdc3-16ad06572e21","offerId":"864A02B3BF7442A4802E6DF7BA2EDA28","productId":"1ZPTYHZN85S6","productName":"Pokemon Assorted Lot of 50 Single Cards [Any Series]","itemId":127446742,"sellerId":"A577588AB81D43AE9E7F468183B3568A","thumbnailUrl":"https://i5.walmartimages.com/asr/aa6ed747-9cd0-44dc-b927-44bc2b7e1ca7_1.62c435484d4015af1c325e9cdeeb3662.jpeg?odnHeight=100&odnWidth=100&odnBg=FFFFFF","legacySellerId":3340,"productClassType":"REGULAR","quantity":1,"unitPrice":8.61,"type":"REGULAR","price":8.61,"unitOfMeasure":"EA","hasCarePlan":false,"brand":"Pok?mon","discount":{},"rhPath":"20000:25000:25003:25114:25333","isWarrantyEligible":false,"category":"0:4171:3318550:617941:8920388","primaryCategory":"Home Page/Toys/Shop Toys by Age/Toys for Kids 5 to 7 Years/Toys for Kids 5 to 7 Years","isCarePlan":false,"isEgiftCard":false,"isAssociateDiscountEligible":false,"isShippingPassEligible":false,"isTwoDayShippingEligible":false,"classId":"5","maxQuantityPerOrder":100,"isSubstitutable":false,"isInstaWatch":false,"isAlcoholic":false,"isSnapEligible":false,"isAgeRestricted":false,"isSubstitutionsAllowed":false,"fulfillmentSelection":{"fulfillmentOption":"S2H","shipMethod":"STANDARD","availableQuantity":172},"servicePlanType":"NONE","errors":[],"wfsEnabled":false,"isAlcohol":false}],"shipping":{"postalCode":"82001","city":"CHEYENNE","state":"WY"},"promotions":[{"promotionId":"1c2cbad1-205e-425f-9297-8629d68e97f6","okToPayAwards":[{"applyTo":"CART_FULFILLMENT_PRICE","actionType":"AWARD","name":"DS_Donors_Choose_Teachers_Card","awardType":"OK_TO_PAY","description":"DonorsChoose Card","applicableTo":{"ITEM_TAX":true,"SHIP_PRICE":true,"SHIP_TAX":true,"FEE":true,"ITEM_PRICE":true},"asset":{"image":"https://i5.walmartimages.com/dfw/63fd9f59-e0cf/455269aa-c4e8-46a5-8d76-5d4b458e1269/v1/Select_gift_card.png","imageAlt":""},"awardEligibleItemIds":[],"awardEligibleTotalsByItemId":{}}],"dsEligibleItemIds":[],"dsEligibleTotals":{}}],"summary":{"subTotal":8.61,"shippingIsEstimate":false,"taxIsEstimate":true,"grandTotal":8.61,"quantityTotal":1,"amountOwed":8.61,"merchandisingFeesTotal":0,"shippingCosts":[{"label":"Top Cut Central shipping","type":"marketplace_shipping","cost":0.0}],"shippingTotal":0.0,"hasSurcharge":false,"preTaxTotal":8.61,"addOnServicesTotal":0,"itemsSubTotal":8.61},"pickupPeople":[],"email":"","buyer":{"customerAccountId":"9afb345e-74b8-4afb-93d0-4bf52697e18f","isGuestSignupRequired":false,"isGuest":true,"isAssociate":false,"applyAssociateDiscount":false},"allowedPaymentTypes":[{"type":"CREDITCARD","cvvRequired":true},{"type":"PAYPAL","cvvRequired":false},{"type":"GIFTCARD","cvvRequired":false},{"type":"VISA_CHECKOUT","cvvRequired":false},{"type":"MASTERPASS","cvvRequired":false},{"type":"CHASEPAY","cvvRequired":false},{"type":"AMEX_CHECKOUT","cvvRequired":false}],"registries":[],"payments":[],"cardsToDisable":[],"allowedPaymentPreferences":[],"isRCFEligible":false,"isMarketPlaceItemsExist":true,"version":"v3","shippingCategory":{"shippingGroups":[{"itemIds":["918e337d-82ae-4e91-bdc3-16ad06572e21"],"seller":"Top Cut Central","defaultSelection":true,"fulfillmentOption":"S2H","shippingGroupOptions":[{"method":"EXPEDITED","methodDisplay":"Expedited","selected":false,"charge":8.99,"deliveryDate":1606766400000,"availableDate":1606766400000,"fulfillmentOption":"S2H","onlineStoreId":0,"isThresholdShipMethod":false},{"method":"STANDARD","methodDisplay":"Standard","selected":true,"charge":0.0,"deliveryDate":1606939200000,"availableDate":1606939200000,"fulfillmentOption":"S2H","onlineStoreId":0,"isThresholdShipMethod":false}],"isEdelivery":false,"hasWFSItem":false,"itemSellerGroups":[]}]},"entityErrors":[],"oneDaySelected":false,"paymentWithBagFee":false,"giftDetails":{"giftOrder":false,"hasGiftEligibleItem":false,"xoGiftingOptIn":false},"canApplyDetails":[],"dbName":"e5b96399-fefc-4d9d-93ba-2aa1059008ce|C","jwt":"eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI1MjdmZTRjYi0wZjI5LTRjZWYtOWRiOS00Yzc1YWQ5MTMwNTQiLCJpYXQiOjE2MDYwOTY0NjMsImlzcyI6IjU3YjM0ZTNhZGE1MjkzMGEwYzBjYTFjOSIsIk9yZ1VuaXRJZCI6IjU2ZWJiMTJkZGE1MjkzMWRhOGZlMDc5YSIsIlJlZmVyZW5jZUlkIjoiZTViOTYzOTktZmVmYy00ZDlkLTkzYmEtMmFhMTA1OTAwOGNlIn0.-ta5UQLkJtXNR5yP2dOhDiDMF9dPpbfktAJu7z22kNM"}
Edit Below! Edit Below! Edit Below!
For future visitors -
I like to use split to find what I specifically need. For example for this problem I had above. I would just use
let myId = string.split(`"itemIds":["`)[1].split('"')[0]
This should work well and I use this method all the time. If you have any better methods feel free to reply or leave an answer. You can also use JSON.parse(your data) and look for your specific variable that way. This article should also help you understand how to use it. https://www.tutorialrepublic.com/javascript-tutorial/javascript-json-parsing.php

First you need to determine which prop will you get the value of? And then try this, in this case I will get "itemIds" so my findProp function will take 2 parameters:
const myObj = {
dbSessionTokenMap: {
CXO_PC_ST:
'e5b96399-fefc-4d9d-93ba-2aa1059008ce|{"mtoken":"301:12#90271897#2=60818072#7=100439087"}',
},
id: "e5b96399-fefc-4d9d-93ba-2aa1059008ce",
checkoutFlowType: "Guest",
cartId: "ffd6cb2f-efc2-47b2-96d9-52d2cfb3d69b",
items: [
{
id: "918e337d-82ae-4e91-bdc3-16ad06572e21",
offerId: "864A02B3BF7442A4802E6DF7BA2EDA28",
productId: "1ZPTYHZN85S6",
productName: "Pokemon Assorted Lot of 50 Single Cards [Any Series]",
itemId: 127446742,
sellerId: "A577588AB81D43AE9E7F468183B3568A",
thumbnailUrl:
"https://i5.walmartimages.com/asr/aa6ed747-9cd0-44dc-b927-44bc2b7e1ca7_1.62c435484d4015af1c325e9cdeeb3662.jpeg?odnHeight=100&odnWidth=100&odnBg=FFFFFF",
legacySellerId: 3340,
productClassType: "REGULAR",
quantity: 1,
unitPrice: 8.61,
type: "REGULAR",
price: 8.61,
unitOfMeasure: "EA",
hasCarePlan: false,
brand: "Pok?mon",
discount: {},
rhPath: "20000:25000:25003:25114:25333",
isWarrantyEligible: false,
category: "0:4171:3318550:617941:8920388",
primaryCategory:
"Home Page/Toys/Shop Toys by Age/Toys for Kids 5 to 7 Years/Toys for Kids 5 to 7 Years",
isCarePlan: false,
isEgiftCard: false,
isAssociateDiscountEligible: false,
isShippingPassEligible: false,
isTwoDayShippingEligible: false,
classId: "5",
maxQuantityPerOrder: 100,
isSubstitutable: false,
isInstaWatch: false,
isAlcoholic: false,
isSnapEligible: false,
isAgeRestricted: false,
isSubstitutionsAllowed: false,
fulfillmentSelection: {
fulfillmentOption: "S2H",
shipMethod: "STANDARD",
availableQuantity: 172,
},
servicePlanType: "NONE",
errors: [],
wfsEnabled: false,
isAlcohol: false,
},
],
shipping: { postalCode: "82001", city: "CHEYENNE", state: "WY" },
promotions: [
{
promotionId: "1c2cbad1-205e-425f-9297-8629d68e97f6",
okToPayAwards: [
{
applyTo: "CART_FULFILLMENT_PRICE",
actionType: "AWARD",
name: "DS_Donors_Choose_Teachers_Card",
awardType: "OK_TO_PAY",
description: "DonorsChoose Card",
applicableTo: {
ITEM_TAX: true,
SHIP_PRICE: true,
SHIP_TAX: true,
FEE: true,
ITEM_PRICE: true,
},
asset: {
image:
"https://i5.walmartimages.com/dfw/63fd9f59-e0cf/455269aa-c4e8-46a5-8d76-5d4b458e1269/v1/Select_gift_card.png",
imageAlt: "",
},
awardEligibleItemIds: [],
awardEligibleTotalsByItemId: {},
},
],
dsEligibleItemIds: [],
dsEligibleTotals: {},
},
],
summary: {
subTotal: 8.61,
shippingIsEstimate: false,
taxIsEstimate: true,
grandTotal: 8.61,
quantityTotal: 1,
amountOwed: 8.61,
merchandisingFeesTotal: 0,
shippingCosts: [
{
label: "Top Cut Central shipping",
type: "marketplace_shipping",
cost: 0.0,
},
],
shippingTotal: 0.0,
hasSurcharge: false,
preTaxTotal: 8.61,
addOnServicesTotal: 0,
itemsSubTotal: 8.61,
},
pickupPeople: [],
email: "",
buyer: {
customerAccountId: "9afb345e-74b8-4afb-93d0-4bf52697e18f",
isGuestSignupRequired: false,
isGuest: true,
isAssociate: false,
applyAssociateDiscount: false,
},
allowedPaymentTypes: [
{ type: "CREDITCARD", cvvRequired: true },
{ type: "PAYPAL", cvvRequired: false },
{ type: "GIFTCARD", cvvRequired: false },
{ type: "VISA_CHECKOUT", cvvRequired: false },
{ type: "MASTERPASS", cvvRequired: false },
{ type: "CHASEPAY", cvvRequired: false },
{ type: "AMEX_CHECKOUT", cvvRequired: false },
],
registries: [],
payments: [],
cardsToDisable: [],
allowedPaymentPreferences: [],
isRCFEligible: false,
isMarketPlaceItemsExist: true,
version: "v3",
shippingCategory: {
shippingGroups: [
{
itemIds: ["918e337d-82ae-4e91-bdc3-16ad06572e21"],
seller: "Top Cut Central",
defaultSelection: true,
fulfillmentOption: "S2H",
shippingGroupOptions: [
{
method: "EXPEDITED",
methodDisplay: "Expedited",
selected: false,
charge: 8.99,
deliveryDate: 1606766400000,
availableDate: 1606766400000,
fulfillmentOption: "S2H",
onlineStoreId: 0,
isThresholdShipMethod: false,
},
{
method: "STANDARD",
methodDisplay: "Standard",
selected: true,
charge: 0.0,
deliveryDate: 1606939200000,
availableDate: 1606939200000,
fulfillmentOption: "S2H",
onlineStoreId: 0,
isThresholdShipMethod: false,
},
],
isEdelivery: false,
hasWFSItem: false,
itemSellerGroups: [],
},
],
},
entityErrors: [],
oneDaySelected: false,
paymentWithBagFee: false,
giftDetails: {
giftOrder: false,
hasGiftEligibleItem: false,
xoGiftingOptIn: false,
},
canApplyDetails: [],
dbName: "e5b96399-fefc-4d9d-93ba-2aa1059008ce|C",
jwt:
"eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI1MjdmZTRjYi0wZjI5LTRjZWYtOWRiOS00Yzc1YWQ5MTMwNTQiLCJpYXQiOjE2MDYwOTY0NjMsImlzcyI6IjU3YjM0ZTNhZGE1MjkzMGEwYzBjYTFjOSIsIk9yZ1VuaXRJZCI6IjU2ZWJiMTJkZGE1MjkzMWRhOGZlMDc5YSIsIlJlZmVyZW5jZUlkIjoiZTViOTYzOTktZmVmYy00ZDlkLTkzYmEtMmFhMTA1OTAwOGNlIn0.-ta5UQLkJtXNR5yP2dOhDiDMF9dPpbfktAJu7z22kNM",
};
const findProp = (obj, prop, out) => {
let i,
proto = Object.prototype,
ts = proto.toString,
hasOwn = proto.hasOwnProperty.bind(obj);
if ("[object Array]" !== ts.call(out)) {
out = [];
}
for (i in obj) {
if (hasOwn(i)) {
if (i === prop) {
out.push(obj[i]);
} else if (
"[object Array]" === ts.call(obj[i]) ||
"[object Object]" === ts.call(obj[i])
) {
findProp(obj[i], prop, out);
}
}
}
return out;
};
console.log(findProp(myObj, "itemIds"));

Related

Kendo Grid Pager Shows No Items To Display

I have defined a Kendo grid as follows:
$(document).ready(function() {
$("#catalogGrid2").kendoGrid(catalogGridOptions);
});
let catalogGridOptions = {
pageable: true,
dataSource: {
serverPaging: true,
//serverGrouping: true,
transport: {
read: {
url: "/gliese/read",
type: "GET",
contentType: "application/json"
}
},
//pageSize: 25,
schema: {
data: "data",
total: "total",
// total: function(response) {
// return response.total;
// },
model: {
id: "catalogID",
fields: {
id: {type: "number"},
name: {type: "string"},
component: {type: "string"}
}
}
},
},
pageable: {
pageSize: 25,
//pageSizes: true,
//pageSizes: [10,25,50,100,"all"],
//input: true,
numeric: true,
refresh: true
},
columns: [
{
field: "id",
hidden: true
},
{
field: "name",
title: "Name",
width: 150
},
{
field: "component",
title: "Component",
width: 75
}
],
};
The data displays correctly in the grid, but there are no pages to navigate through, and the message "No items to display" is in the pager bar as well.
Below is an example of the results being returned:
{
"total": 3803,
"pageSize": 25,
"data": [
{
"id": 12409,
"name": "Sun",
"component": "",
"ra": "00 02 33.8",
"dec": "+00 16 42",
"properMotion": null,
"properMotionDir": null,
"radialVelocity": null,
"spectralTypeFull": "G2 V",
"spectralType": "G",
"spectralTypeSub": "2",
"luminosityClass": "V",
"visualMagnitude": -26.72,
"absoluteMagnitude": 4.85,
"parallax": null,
"bvColor": 0.65,
"hd": null
},
// 24 more results
]
}
Does anyone see any obvious reasons why the pager bar does not work?
EDIT: Added screenshot per request, updated code to newest attempt.

Rate exceeded error when calling AWS CloudFront update

I have to delete CloudFront distribution using AWS SDK for JavaScript so I'm trying to update it first, but when I sent the request I'm getting Rate exceeded internal server error. I tried many different values inside my config but it always returns this rate error. I'm not sure if it's problem with configuration or maybe I did something else wrong. I have also created function that creates new distribution and it works fine.
My current config object looks like this:
const originId = `S3-${buckets.build.name}`;
const originDomain = `${buckets.build.name}.s3.amazonaws.com`;
const updateParams: CloudFront.UpdateDistributionRequest = {
Id: distribution.id,
IfMatch: distribution.eTag,
DistributionConfig: {
DefaultRootObject: 'index.html',
CallerReference: caller,
Comment: 'Zilo catalog',
DefaultCacheBehavior: {
AllowedMethods: {
Items: ['HEAD', 'GET'],
Quantity: 2,
CachedMethods: {
Items: ['HEAD', 'GET'],
Quantity: 2,
},
},
TargetOriginId: originId,
ViewerProtocolPolicy: 'allow-all',
MinTTL: 3600,
SmoothStreaming: false,
Compress: false,
DefaultTTL: 5000,
FieldLevelEncryptionId: '',
MaxTTL: 10000,
LambdaFunctionAssociations: {
Quantity: 0,
Items: [],
},
ForwardedValues: {
QueryString: true,
Cookies: {
Forward: 'all',
},
Headers: {
Quantity: 0,
Items: [],
},
QueryStringCacheKeys: {
Quantity: 0,
Items: [],
},
},
},
Enabled: false,
Origins: {
Items: [
{
DomainName: originDomain,
Id: originId,
CustomOriginConfig: {
HTTPPort: 80,
HTTPSPort: 443,
OriginProtocolPolicy: 'match-viewer',
OriginSslProtocols: { Items: ['SSLv3'], Quantity: 1 },
OriginReadTimeout: 10000,
OriginKeepaliveTimeout: 10000,
},
OriginPath: '',
CustomHeaders: { Quantity: 0 },
},
],
Quantity: 1,
},
Aliases: {
Quantity: 0,
},
Logging: {
Enabled: false,
IncludeCookies: false,
Bucket: '',
Prefix: '',
},
WebACLId: '',
HttpVersion: 'http2',
Restrictions: {
GeoRestriction: {
RestrictionType: 'none',
Quantity: 0,
},
},
ViewerCertificate: {
MinimumProtocolVersion: 'SSLv3',
},
CustomErrorResponses: {
Items: [],
Quantity: 0,
},
PriceClass: 'PriceClass_100',
CacheBehaviors: { Quantity: 0, Items: [] },
},
};
Any ideas what could gone wrong here?
Ran into this same issue while attempting to disable CloudFront distribution before deleting it. Ended up finding this working solution in Java:
GetDistributionConfigResponse distributionConfigResponse =
cloudFrontClient.getDistributionConfig(GetDistributionConfigRequest.builder().id(distributionId).build());
distributionETag = distributionConfigResponse.eTag();
DistributionConfig originalConfig = distributionConfigResponse.distributionConfig();
UpdateDistributionResponse updateDistributionResponse =
cloudFrontClient.updateDistribution(r -> r.id(distributionId)
.ifMatch(distributionETag)
.distributionConfig(originalConfig.toBuilder()
.enabled(false)
.build()));

Sequelize association methods attribures

I have a struggle with associations method. I have users and lists with many to many association, so the sequelize generate for me method user.getLists(); But when I call that mehod result is
[
{
"id": 1,
"title": "Boop",
"created_at": "2018-08-15T14:53:51.276Z",
"updated_at": "2018-08-15T14:53:51.276Z",
"deleted_at": null,
"user_list": {
"owner": true,
"created_at": "2018-08-15T14:53:51.290Z",
"updated_at": "2018-08-15T14:53:51.290Z",
"deleted_at": null,
"user_id": 1,
"list_id": 1
}
}
]
And I can't find a way to remove user_list attribute from it or rename it.
Is there a way to remove this attribute on ORM level or rename it?
For example this is not working:
user.getLists({ attributes: ['id'] });
user.getLists({ attributes: [['user_list', 'random_name']] });
My models look like this
User model:
const user = db.define(
'user',
{
id: {
type: sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
email: {
type: sequelize.STRING,
unique: 'email_unique',
allowNull: false,
validate: {
isEmail: true,
},
},
});
List model:
const list = db.define(
'list',
{
id: {
type: sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
title: {
type: sequelize.STRING,
allowNull: false,
},
},
);
UserList:
const userList = db.define(
'user_list',
{
owner: {
type: sequelize.BOOLEAN,
allowNull: false,
},
},
);
Associations:
User.belongsToMany(
List,
{
through: UserList,
as: {
singular: 'List',
plural: 'Lists',
},
})
List.belongsToMany(User, { through: UserList });

Sequelize returning more fields than requested

I have this function,
module.exports.getDepartments = function () {
return new Promise(function (resolve, reject) {
sequelize.sync().then(function () {
Departments.findAll({
attributes: ['departmentId', 'departmentName']
}).then(function(data){
resolve(data);
}).catch(function(err) {
reject("Error: " + err);
})
});
}
)};
And when I console.log() the data, I get all records with all these weird fields!
Departments {
dataValues: { departmentId: 5, departmentName: '' },
_previousDataValues: { departmentId: 5, departmentName: '' },
_changed: {},
_modelOptions:
{ timestamps: true,
validate: {},
freezeTableName: false,
_options:
{ isNewRecord: false,
_schema: null,
_schemaDelimiter: '',
raw: true,
attributes: [ 'departmentId', 'departmentName' ] },
__eagerlyLoadedAssociations: [],
isNewRecord: false }
Departments {
dataValues: { departmentId: 6, departmentName: 'TEST' },
_previousDataValues: { departmentId: 6, departmentName: 'TEST' },
_changed: {},
_modelOptions:
{ timestamps: true,
validate: {},
freezeTableName: false,
_options:
{ isNewRecord: false,
_schema: null,
_schemaDelimiter: '',
raw: true,
attributes: [ 'departmentId', 'departmentName' ] },
__eagerlyLoadedAssociations: [],
isNewRecord: false }
I've had to shorten it by like 20 fields, but you get the idea. What's going on? This is preventing me from running res.render back on my server.js because it's expecting on departmentId and departmentName, but is getting way more.
You need to instruct Sequelize to return raw data. By default it creates instances on the row results.
Example:
Project.findAll({ where: { ... }, raw: true })

Why am I only getting one association with this model?

Using Sequelize for Node.js I have defined some relationships. The only issue is that the promotion models contain just one gamePlayLog each instead of all for each. The example promotion below should have over 100 gamePlayLogs's. I copied just one from the array of returned promotions/tournaments for reference. Am I doing something wrong?
var Sequelize = require('sequelize'),
seqlz = new Sequelize('wegweg', 'wegwegweg', 'wegwegweg!', {
host: '...',
port: '3306',
dialect: 'mysql',
timezone: 'UTC-05:00',
pool: {
max: 5,
min: 0,
idle: 10000
}
}),
Promotion = seqlz.define('promotion', {
tournamentId: {
type: Sequelize.BIGINT(20),
primaryKey: true
},
iconFilePath: Sequelize.STRING,
name: Sequelize.STRING(75),
eventStartDate: Sequelize.DATE,
eventEndDate: Sequelize.DATE
}, {
timestamps: false,
tableName: 'Tournament'
}),
Advertiser = seqlz.define('advertiser', {
advertiserId: {
type: Sequelize.BIGINT(20),
primaryKey: true
},
name: Sequelize.STRING(75),
}, {
timestamps: false,
tableName: 'Advertiser'
}),
Game = seqlz.define('game', {
gameId: {
type: Sequelize.BIGINT(20),
primaryKey: true
},
name: Sequelize.STRING(75)
}, {
timestamps: false,
tableName: 'Game'
}),
GamePlayLog = seqlz.define('gamePlayLog', {
gamePlayLogId: {
type: Sequelize.BIGINT(20),
primaryKey: true
},
createdDate: Sequelize.DATE
}, {
timestamps: false,
tableName: 'GamePlayLog'
});
Promotion.belongsTo(Advertiser, {foreignKey: 'advertiserId'});
Promotion.belongsTo(Game, {foreignKey: 'gameId'});
Promotion.hasMany(GamePlayLog, {foreignKey: 'gamePlayLogId'});
exports.handler = function(event, context) {
Promotion.findAll({
where: {status: 3},
include: [Advertiser, Game, GamePlayLog]
}).then(function(promos) {
context.done(null, promos);
});
};
{
"tournamentId": 607,
"iconFilePath": "uploadfiles/tournament/icon/...-mobile-icon.jpg",
"name": "Win Custom Artwork",
"eventStartDate": "2015-07-27T05:00:00.000Z",
"eventEndDate": "2016-08-02T04:00:00.000Z",
"advertiserId": 37,
"gameId": 14,
"advertiser": {
"advertiserId": 37,
"name": "...Customs"
},
"game": {
"gameId": 14,
"name": "Eggcetera"
},
"gamePlayLogs": [
{
"gamePlayLogId": 607,
"createdDate": "2015-02-26T13:31:34.000Z"
}
]
}
You're specifying the foreign key as the gamePlayerLogId but that's a primary key in the gamePlayerLog table so there will only ever be one with a corresponding id. I think what you probably want is to specify the promotion id in the gamePlayerLog table as the foreign key.

Categories

Resources