local cart = {}

cart.setdb = function(db)
  cart.db = db
end

cart.newForUser = function(user_record)
  local cart_record = {['type']='cart', lineitem_ids={}, user_id=user_record.id}
  cart.db:insertrecord(cart_record)
  user_record.current_cart_id = cart_record.id
  user_record:save()
  return cart_record
end

return cart