lepozepo / online_shop Goto Github PK
View Code? Open in Web Editor NEWThis is the end project for the book I am publishing by the end of the year
This is the end project for the book I am publishing by the end of the year
Page 38 - "We need to publish three different collections to have all the information that our cart needs: Orders, OrderDetails, and Products. This publisher can follow the same logic that we found in the rst publisher:"
Meteor.publish "cart", (ops={}) ->
if ops.order and not _.isEmpty ops.order
@relations
collection:Orders
filter:
_id:ops.order
status:"new"
mappings:[
{
key:"order"
collection:OrderDetails
options:
limit:25
mappings:[
{
foreign_key:"product"
collection:Products
} ]
What do you mean by ops?
The app crashes after
@products = new Mongo.Collection "products"
if Meteor.isServer
if Products.find().count() is 0
Products.insert
name:"Nuka Cola"
price: 1099
Products.insert
name:"1up Soda"
price: 999
Products.insert
name:"JuggerNog"
price: 899
this is the error
W20151105-16:12:00.278(-6)? (STDERR)
W20151105-16:12:00.278(-6)? (STDERR) /Users/ObookPro/.meteor/packages/meteor-tool/.1.1.10.4nyfu9++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20151105-16:12:00.278(-6)? (STDERR) throw(ex);
W20151105-16:12:00.279(-6)? (STDERR) ^
W20151105-16:12:00.387(-6)? (STDERR) Error: A method named '/products/insert' is already defined
W20151105-16:12:00.387(-6)? (STDERR) at livedata_server.js:1542:15
W20151105-16:12:00.387(-6)? (STDERR) at Function..each..forEach (packages/underscore/underscore.js:113:1)
W20151105-16:12:00.387(-6)? (STDERR) at [object Object]._.extend.methods (livedata_server.js:1538:7)
W20151105-16:12:00.387(-6)? (STDERR) at [object Object].Mongo.Collection._defineMutationMethods (packages/mongo/collection.js:927:1)
W20151105-16:12:00.388(-6)? (STDERR) at new Mongo.Collection (packages/mongo/collection.js:218:1)
W20151105-16:12:00.388(-6)? (STDERR) at products/collections/productcol.coffee:1:17
W20151105-16:12:00.388(-6)? (STDERR) at products/collections/productcol.coffee:1:1
W20151105-16:12:00.388(-6)? (STDERR) at /Users/ObookPro/online_shop/.meteor/local/build/programs/server/boot.js:242:10
W20151105-16:12:00.388(-6)? (STDERR) at Array.forEach (native)
W20151105-16:12:00.389(-6)? (STDERR) at Function..each..forEach (/Users/ObookPro/.meteor/packages/meteor-tool/.1.1.10.4nyfu9++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
I cloned this online shop to give it a try. But I keep getting this error
is it normal?
Exception while simulating the effect of invoking 'cart.add-to-cart'
"Match error: Failed Match.OneOf or Match.Optional validation in field order", path: "order", sanitizedError: errorClass, errorType: "Match.Error"} Error: Match error: Failed Match.OneOf or Match.Optional validation in field order
at check (http://localhost:3000/packages/check.js?9c4972d3f4fe56cd455d3022e70b5195e642fc41:61:15)
at Meteor.methods.cart.add-to-cart (http://localhost:3000/app/orders/cart/cart_methods.coffee.js?78139a7f7d35cc7cfb159359dd8d1842e832631b:16:5)
at http://localhost:3000/packages/ddp-client.js?250b63e6c919c5383a0511ee4efbf42bb70a650f:3911:25
at _.extend.withValue (http://localhost:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:971:17)
at _.extend.apply (http://localhost:3000/packages/ddp-client.js?250b63e6c919c5383a0511ee4efbf42bb70a650f:3902:54)
at _.extend.call (http://localhost:3000/packages/ddp-client.js?250b63e6c919c5383a0511ee4efbf42bb70a650f:3780:17)
at Object.Template.product.events.click button.add-to-cart (http://localhost:3000/app/products/client/product.coffee.js?e51be2e49ac43f0fd1ac1e5b890310c73c7835a4:32:19)
at http://localhost:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:3697:20
at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:3671:12)
at null. (http://localhost:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:3696:25)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.