use mabolo.bind

This commit is contained in:
jysperm
2015-06-03 17:08:09 +08:00
parent 61d7a7ee34
commit ef57e227c9
9 changed files with 38 additions and 37 deletions

View File

@@ -1,15 +1,14 @@
validator = require 'validator'
Mabolo = require 'mabolo'
_ = require 'lodash'
utils = require '../utils'
{mabolo} = root
###
Model: Account Session Token Model,
Embedded as a array at `tokens` of {Account}.
###
Token = mabolo.model 'Token',
Token = Mabolo.model 'Token',
# Public: Type of token
type:
required: true
@@ -42,7 +41,7 @@ Token = mabolo.model 'Token',
TODO: verify fields
###
Preferences = mabolo.model 'Preferences',
Preferences = Mabolo.model 'Preferences',
# Public: A url refer to a avatar of account
avatar_url: String
# Public: A language code, e.g. `zh-CN`
@@ -55,7 +54,7 @@ Preferences = mabolo.model 'Preferences',
###
Model: Account Model.
###
module.exports = Account = mabolo.model 'Account',
module.exports = Account = Mabolo.model 'Account',
# Public: User name
username:
required: true

View File

@@ -1,14 +1,14 @@
Mabolo = require 'mabolo'
_ = require 'lodash'
Q = require 'q'
{mabolo} = root
{ObjectID} = mabolo
{ObjectID} = Mabolo
###
Model: Component coworker,
Embedded as a array at `coworkers` of {Component}.
###
Coworker = mabolo.model 'Coworker',
Coworker = Mabolo.model 'Coworker',
# Public: Related account
account_id:
required: true
@@ -24,7 +24,7 @@ Coworker = mabolo.model 'Coworker',
###
Model: Component.
###
module.exports = Component = mabolo.model 'Component',
module.exports = Component = Mabolo.model 'Component',
# Public: Owner account
account_id:
required: true

View File

@@ -1,16 +1,16 @@
Mabolo = require 'mabolo'
_ = require 'lodash'
Q = require 'q'
utils = require '../utils'
{mabolo} = root
{ObjectID} = mabolo
{ObjectID} = Mabolo
###
Model: Apply log of CouponCode,
Embedded as a array at `apply_log` of {CouponCode}.
###
ApplyLog = mabolo.model 'ApplyLog',
ApplyLog = Mabolo.model 'ApplyLog',
# Public: Related account
account_id:
required: true
@@ -24,7 +24,7 @@ ApplyLog = mabolo.model 'ApplyLog',
###
Model: CouponCode.
###
module.exports = CouponCode = mabolo.model 'CouponCode',
module.exports = CouponCode = Mabolo.model 'CouponCode',
# Public: Code of coupon
code:
required: true

View File

@@ -1,12 +1,12 @@
Mabolo = require 'mabolo'
Q = require 'q'
{mabolo} = root
{ObjectID} = mabolo
{ObjectID} = Mabolo
###
Model: Financials.
###
module.exports = Financials = mabolo.model 'Financials',
module.exports = Financials = Mabolo.model 'Financials',
# Public: Related account
account_id:
required: true

View File

@@ -1,13 +1,13 @@
Mabolo = require 'mabolo'
_ = require 'lodash'
Q = require 'q'
{mabolo} = root
{ObjectID} = mabolo
{ObjectID} = Mabolo
###
Model: Notification.
###
module.exports = Notification = mabolo.model 'Notification',
module.exports = Notification = Mabolo.model 'Notification',
# Public: Plugin that created this notification
source:
required: true

View File

@@ -1,12 +1,12 @@
Mabolo = require 'mabolo'
_ = require 'lodash'
{mabolo} = root
{ObjectID} = mabolo
{ObjectID} = Mabolo
###
Model: Security log
###
module.exports = SecurityLog = mabolo.model 'SecurityLog',
module.exports = SecurityLog = Mabolo.model 'SecurityLog',
# Public: Related account
account_id:
required: true

View File

@@ -1,15 +1,15 @@
{markdown} = require 'markdown'
Mabolo = require 'mabolo'
_ = require 'lodash'
Q = require 'q'
{mabolo} = root
{ObjectID} = mabolo
{ObjectID} = Mabolo
###
Model: Ticket reply,
Embedded as a array at `replies` of {Ticket}.
###
Reply = mabolo.model 'Reply',
Reply = Mabolo.model 'Reply',
# Public: Related account
account_id:
required: true
@@ -34,7 +34,7 @@ Reply = mabolo.model 'Reply',
###
Model: Ticket.
###
module.exports = Ticket = mabolo.model 'Ticket',
module.exports = Ticket = Mabolo.model 'Ticket',
# Public: Related account
account_id:
required: true
@@ -78,6 +78,8 @@ module.exports = Ticket = mabolo.model 'Ticket',
type: Date
default: -> new Date()
Account = require './account'
###
Public: Create ticket.
@@ -270,5 +272,3 @@ Ticket::populateAccounts = ->
return reply.account_id.equals _id
return @
Account = require './account'

View File

@@ -104,9 +104,11 @@ module.exports = class Root extends EventEmitter
start: ->
CacheFactory = require './cache'
mabolo = new Mabolo mongodbUri @config.mongodb
_.extend @,
express: express()
mabolo: new Mabolo mongodbUri @config.mongodb
mabolo: mabolo
mailer: nodemailer.createTransport @config.email.account
insight: new Insight
@@ -117,13 +119,13 @@ module.exports = class Root extends EventEmitter
cache: new CacheFactory @config.redis
_.extend @,
Account: require './model/account'
Financials: require './model/financials'
CouponCode: require './model/coupon-code'
Notification: require './model/notification'
SecurityLog: require './model/security-log'
Ticket: require './model/ticket'
Component: require './model/component'
Account: mabolo.bind require './model/account'
Financials: mabolo.bind require './model/financials'
CouponCode: mabolo.bind require './model/coupon-code'
Notification: mabolo.bind require './model/notification'
SecurityLog: mabolo.bind require './model/security-log'
Ticket: mabolo.bind require './model/ticket'
Component: mabolo.bind require './model/component'
HookRegistry = require './registry/hook'
ViewRegistry = require './registry/view'

View File

@@ -43,7 +43,7 @@
"jade": "^1.9.2",
"json-stable-stringify": "^1.0.0",
"lodash": "^3.6.0",
"mabolo": "^0.3.0",
"mabolo": "^0.3.1",
"markdown": "^0.5.0",
"moment-timezone": "^0.2.5",
"mongodb": "^2.0.7",