This repository has been archived by the owner on Jan 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shopQueries.json
1 lines (1 loc) · 3.32 KB
/
shopQueries.json
1
[{"name":"01ShowNewCustomersSince2016","parameter":{},"value":"// Show new customers since 2016\nFOR c IN customers\n FILTER c.memberSince >= \"2016\"\n RETURN c\n"},{"name":"02CountAllCustomers","parameter":{},"value":"// Count all customers\nFOR c IN customers\n COLLECT WITH COUNT INTO count\n RETURN {\"number of customers\": count}\n"},{"name":"03CountNewCustomersIn2015","parameter":{},"value":"// Count new customers in 2015\nFOR c IN customers\n FILTER c.memberSince >= \"2015\" && c.memberSince < \"2016\"\n COLLECT WITH COUNT INTO count\n RETURN {\"number of new customers in 2015\": count}\n"},{"name":"04StatisticsSignupByYears","parameter":{},"value":"// Statistics about signups by year\nFOR c IN customers\n COLLECT y = SUBSTRING(c.memberSince, 0, 4) WITH COUNT INTO count\n SORT y DESC\n RETURN { year: y, noNewCustomers: count }\n"},{"name":"05Show10FirstItemsWithPriceAtLeast200","parameter":{},"value":"// Show 10 first items with a price of at least 200\nFOR i IN items\n FILTER i.price >= 200\n LIMIT 10\n RETURN i\n"},{"name":"06ShowSalesOctober2016","parameter":{},"value":"// Show sales October 2016\nFOR s IN sales\n FILTER s.date >= \"2016-10-01\" && s.date < \"2016-11-01\"\n SORT s.date\n RETURN { date: s.date, billingId: s.billingId }\n"},{"name":"07JoinThePrice","parameter":{},"value":"// Join the price\nFOR s IN sales\n FILTER s.date >= \"2016-10-01\" && s.date < \"2016-11-01\"\n SORT s.date\n FOR i IN items\n FILTER i._id == s._to\n RETURN { date: s.date, billingId: s.billingId, price: i.price }\n"},{"name":"08ShowCompleteOrders","parameter":{},"value":"// Show complete orders\nFOR s IN sales\n FOR i IN items\n FILTER i._id == s._to\n COLLECT bill = s.billingId INTO items\n FOR c IN customers\n FILTER c._id == items[0].s._from\n RETURN { date: items[0].s.date, billingId: bill,\n name: c.name, price: SUM(items[*].i.price),\n items: items[*].i }\n"},{"name":"09FindTopSellersUsingGraph","parameter":{},"value":"// Find top sellers (using graph)\nFOR item IN items\n LET buyers = (FOR v IN 1..1 INBOUND item GRAPH \"sales\" RETURN v)\n LET nr = LENGTH(buyers)\n SORT nr DESC\n RETURN { description: item.description, orderId: item.orderId, nrSales: nr }\n"},{"name":"10FindAllItemsBoughtByGivenCustomer","parameter":{},"value":"// Given a customer, find all items he bought\nLET customer = DOCUMENT(\"customers/hugo\")\nFOR i IN 1..1 OUTBOUND customer GRAPH \"sales\"\n COLLECT orderId = i.orderId INTO list\n RETURN { orderId, description: list[0].i.description, count: LENGTH(list),\n customer }\n"},{"name":"11FindRecommendations","parameter":{},"value":"// Given a customer, find all items that somebody has bought, who has bought\n// the same item as the original customer:\nLET customer = DOCUMENT(\"customers/alice\")\nFOR i, e, p IN 3..3 ANY customer GRAPH \"sales\"\n OPTIONS { uniqueVertices: \"none\", uniqueEdges: \"none\" }\n FILTER p.vertices[2]._key != customer._key\n COLLECT orderId = i.orderId INTO list\n RETURN { orderId, description: list[0].i.description, count: LENGTH(list),\n customer: customer.name, path: list[0].p.vertices[*]._key }\n"},{"value":"WITH V\nFOR v, e, p IN 1..1 OUTBOUND \"V/K1\" E\n FILTER p.edges[*].timestamp ALL >= 123 && p.edges[*].timestamp ALL <= 130\n RETURN e\n ","parameter":{},"name":"supernode"}]