party_bid三种数据结构总结
写完三种数据结构有段时间了,现在说一下我的认识,三种数据结构各有优势,
1.第一种是这样的:
activities = [ { name: "first activity", sign_ups:[], bids:[] }, { name: "second activity", sign_ups: [ {name:"张三",phone:"13600000000"} ,{name:"李四",phone:"13600000000"}] bids:[ {name:"竞价1", biddings :[] },{name:"竞价2", biddings : [{name: "张三", phone:"13600000000", price: "10"}] }] }];
bidding.save_bid_=function(activity,phone,bid){ var bids= _.map(activity.bids, function (bid) { if (bid.name == localStorage.current_bid) { var bidder = new bidding(localStorage.current_name, phone, bid) bid.biddings.push(bidder) } return bid })
activities = { "0":{ name: "first activity", sign_ups:[], bids:[], biddings:{} }, "1": { name: "second activity", sign_ups: [ {name:"张三", phone:"13600000000" }] bids:["竞价1","竞价2"], biddings:{ "竞价1":[ {phone:"13600000000", price: "12"}, {phone:"15600000000",price: "10"}] "竞价2":[ {phone:"13600000000",price: "10"}] }}
activities = [{id:"0", name: "first activity" },{id:"1", name: "second activity"}] sign_ups = [{name:"张三",phone:"13600000000",activity_id:"0"}, {name:"李四",phone:"13600000000",activity_id:"0"}, {name:"王五",phone:"15600000000",activity_id:"0"} ] bids = [{name: "竞价1",activity_id:"0",biddings[]}, {name: "竞价1",activity_id:"1",biddings[ {phone:"13600000000", price: "12"}, {phone:"15600000000",price: "10"}]}]