42.Merchant -为一个购买订单做准备

SELECT purchases, product, customer
FROM purchases USE KEYS "purchase0" UNNEST purchases.lineItems AS items
JOIN product ON KEYS items.product
JOIN customer ON KEYS purchases.customerIdLast updated

SELECT purchases, product, customer
FROM purchases USE KEYS "purchase0" UNNEST purchases.lineItems AS items
JOIN product ON KEYS items.product
JOIN customer ON KEYS purchases.customerIdLast updated
{
"results": [
{
"customer": {
"ccInfo": {
"cardExpiry": "2012-11-12",
"cardNumber": "1234-2121-1221-1211",
"cardType": "americanexpress"
},
"customerId": "customer515",
"dateAdded": "2014-01-06T15:52:16Z",
"dateLastActive": "2014-05-06T15:52:16Z",
"emailAddress": "[email protected]",
"firstName": "Dustin",
"lastName": "Lemke",
"phoneNumber": "1-151-555-5907 x324",
"postalCode": "26384",
"state": "MS",
"type": "customer"
},
"product": {
"categories": [
"Pet Supplies"
],
"color": "white",
"dateAdded": "2014-01-06T15:52:19Z",
"dateModified": "2014-05-06T15:52:19Z",
"description": "This product is available on <a target=\"_blank\" href=\"http://www.amazon.com/gp/product/B007KKU8QE/ref=s9_ri_bw_g199_ir015?pf_rd_m=ATVPDKIKX0DER&pf_rd_s=merchandised-search-8&pf_rd_r=D199F6AF45FA49D6845F&pf_rd_t=101&pf_rd_p=1479925062&pf_rd_i=2619533011\">Amazon.com</a>.",
"imageURL": "http://ecx.images-amazon.com/images/I/51BfRrG%2BdoL._SL300_.jpg",
"name": "Aquarius Aq15005 Aquarius 5 Rounded 5-Gallon Aquarium Kit",
"productId": "product701",
"reviewList": [
"review2505",
"review4108",
"review4160",
"review4866",
"review4908",
"review5519",
"review8101",
"review8720",
"review8981",
"review9116"
],
"type": "product",
"unitPrice": 29
},
"purchases": {
"customerId": "customer515",
"lineItems": [
{
"count": 3,
"product": "product701"
},
{
"count": 4,
"product": "product85"
}
],
"purchaseId": "purchase0",
"purchasedAt": "2014-04-06T15:52:32Z",
"type": "purchase"
}
},
{
"customer": {
"ccInfo": {
"cardExpiry": "2012-11-12",
"cardNumber": "1234-2121-1221-1211",
"cardType": "americanexpress"
},
"customerId": "customer515",
"dateAdded": "2014-01-06T15:52:16Z",
"dateLastActive": "2014-05-06T15:52:16Z",
"emailAddress": "[email protected]",
"firstName": "Dustin",
"lastName": "Lemke",
"phoneNumber": "1-151-555-5907 x324",
"postalCode": "26384",
"state": "MS",
"type": "customer"
},
"product": {
"categories": [
"Kitchen & Dining"
],
"color": "white",
"dateAdded": "2013-11-07T15:52:18Z",
"dateModified": "2014-05-06T15:52:18Z",
"description": "This product is available on <a target=\"_blank\" href=\"http://www.amazon.com/gp/product/B0000DE9B5/ref=s9_ri_bw_g79_ir04?pf_rd_m=ATVPDKIKX0DER&pf_rd_s=merchandised-search-11&pf_rd_r=1C0DBDE1A6234FF8A9DB&pf_rd_t=101&pf_rd_p=1405136162&pf_rd_i=284507\">Amazon.com</a>.",
"imageURL": "http://ecx.images-amazon.com/images/I/21xHRhlFslL._SL300_.jpg",
"name": "Bormioli Rocco Frigoverre Jug with Hermetic Lid, 2-Liters",
"productId": "product85",
"reviewList": [
"review681",
"review3771",
"review4215",
"review5685",
"review5856",
"review5935",
"review6789",
"review7532",
"review7649",
"review9011"
],
"type": "product",
"unitPrice": 14.95
},
"purchases": {
"customerId": "customer515",
"lineItems": [
{
"count": 3,
"product": "product701"
},
{
"count": 4,
"product": "product85"
}
],
"purchaseId": "purchase0",
"purchasedAt": "2014-04-06T15:52:32Z",
"type": "purchase"
}
}
]
}