BidHub-CloudCode

开源静音拍卖应用程序 BidHub 背后的基于 Parse 的大脑。(The Parse-based brains behind BidHub, our open-source silent auction app.)

  • Owner: HubSpot/BidHub-CloudCode
  • Platform: Linux, Mac, Windows
  • License:: Apache License 2.0
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

注意:代码已经不能用了。仅作为学习参考。(编辑:vz)

BidHub Cloud Code 后端

HubSpot 的开源静默拍卖应用程序的后端代码。有关拍卖应用程序项目的概述,请查看我们关于它的博客文章

iOS Android 拍卖应用程序由 Parse 支持,这是一种流行且免费的后端即服务。 Parse 处理数据库,还允许您添加在执行操作时发生的服务器端逻辑(例如客户端发布新的出价)。这个存储库包含所有服务器端逻辑,以及这个有用的自述文件,可以让你设置 Parse。

入门

  1. 注册 Parse
  2. git clone 此存储库并编辑 config/global.json 以包含您的应用程序的名称,应用程序ID和主密钥(您可以在 Parse 中找到这些设置键)。
  3. 安装Parse命令行工具
  4. 从 AuctionAppCloudCode 目录中,运行 parse deploy。

初始化数据库

parse deploy 命令将 cloud/main.js 推送到Parse。您可以在 Parse 中通过转到 Core> Cloud Code 看到它。前两个函数包含在保存 NewBid 之前和之后运行的所有逻辑,并由 Parse 自动运行。第三个是 InitializeForAuction ,它是一个手动作业,它将使用正确的列设置 Item 和 NewBid 表。

要运行该作业,请转到 Core> Jobs 并单击 “Schedule a Job”。使用下面显示的设置: Schedule a Job

安排作业应该会出现在下面的屏幕上。单击“立即运行”以运行该作业。而已!

Run Now

现在,如果你转到 Data(左侧),你应该看到 Item 和 NewBid 表。项目将填充测试对象,并且两者都将包含许多与拍卖相关的列。

Item and NewBid

添加项目

添加项目的最简单方法是直接来自 Parse。转到 Core>Data>Item 并通过 +Row 按钮添加单个项目,或通过 CSV 导入添加多个项目。

数据模型

就是这样!你已经完成了设置,你可以使用 iOSAndroid 应用程序。您还可以获取 Web Panel 以关注拍卖。如果您对数据模型感兴趣,请继续阅读以获取简短说明。

物品

代表销售的东西或服务。

  • allBidders 每个对此商品出价的人的电子邮件地址
  • closetime 在此时间之后,出价已关闭
  • currentPrice 此商品的当前最高出价(如果qty> 1和 qty==n,n 个出价最高)
  • currentWinners 此项目当前获胜者的电子邮件地址(如果数量> 1,则为n个获胜者)
  • description 此项目的长篇描述
  • donorname 捐赠者姓名
  • name 此商品的简称(ish)名称
  • numberOfBids 此商品的总出价数
  • opentime 在此之前,竞标已经结束
  • previousWinners 在最新出价之前赢得此项目的人的电子邮件地址。由服务器端逻辑用于仅向不再赢得项目的人发送推送。
  • price 出价等于或高于此价格
  • qty 这个项目有多少可用。例如,如果3个可用,则最高的3个投标人获胜。

NewBid

表示对商品的单一出价。

  • amt 总投标金额
  • email 投标人的电子邮件(唯一身份证)
  • item 此出价所针对的项目的对象ID
  • name 投标人姓名

Overview

Name With OwnerHubSpot/BidHub-CloudCode
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 2)
PlatformLinux, Mac, Windows
License:Apache License 2.0
Release Count0
Created At2014-12-09 22:18:15
Pushed At2015-04-02 00:46:03
Last Commit At2015-04-01 20:46:03
Stargazers Count50
Watchers Count166
Fork Count44
Commits Count20
Has Issues Enabled
Issues Count2
Issue Open Count1
Pull Requests Count1
Pull Requests Open Count0
Pull Requests Close Count0
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

BidHub Cloud Code Backend

Backend code for HubSpot's open-source silent auction app. For an overview of the auction app project, check out our blog post about it!

The iOS and Android auction apps are backed by Parse, a popular and free backend-as-a-service. Parse handles the database, and also allows you to add server-side logic that occurs when an action is taken (such as a client posting a new bid). This repository contains all of that server-side logic, as well as this helpful README that'll get you set up with Parse.

Getting Started

  1. Sign up for Parse.
  2. git clone this repository and edit config/global.json to include your app's name, application ID, and master key (you can find these in Parse by going to Settings > Keys).
  3. Install the Parse Command Line Tool.
  4. From the AuctionAppCloudCode directory, run parse deploy.

Initializing the Database

The parse deploy command pushed cloud/main.js to Parse. You can see it in Parse by going to Core > Cloud Code. The first two functions contain all of the logic that runs before and after a NewBid is saved, and are run automatically by Parse. The third, InitializeForAuction, is a manual job that will set up your Item and NewBid tables with the correct columns.

To run the job, go to Core > Jobs and click Schedule a Job. Use the settings shown below:
Schedule a Job

Scheduling the job should result in the screen below. Click Run Now to run the job. That's it!

Run Now

Now, if you go to Data (on the left), you should see the Item and NewBid tables. Item will be populated with a Test Object, and both will have a number of auction-related columns.

Item and NewBid

Adding Items

The easiest way to add an item is directly from Parse. Go to Core > Data > Item and add either a single item via the +Row button or many items via a CSV import.

Data Models

That's it! You're all set up, and you can go play with the iOS and Android apps now. You can also grab the Web Panel to keep an eye on the auction. If you're interested in the data models, read on for a short description.

Item

Represents a thing or service for sale.

  • allBidders email addresses of everyone who has bid on this item
  • closetime after this time, bidding is closed
  • currentPrice current highest bid on this item (if qty > 1 and qty == n, highest n bids)
  • currentWinners email address of the current winner of this item (or n winners if qty > 1)
  • description long-form description of this item
  • donorname name of donor
  • name short(ish) name for this item
  • numberOfBids total number of bids for this item
  • opentime before this time, bidding is closed
  • previousWinners email address(es) of who was winning this item before the latest bid. Used by the server-side logic to send pushes only to people who are no longer winning an item.
  • price bids start at or above this price
  • qty how many of this item is available. For example, if 3 are available, the highest 3 bidders win.

NewBid

Represents a single bid on an item.

  • amt total dollar amount of bid
  • email Bidder's email (unique ID)
  • item objectId of item this bid is for
  • name Bidder's name
To the top