Skip to content

Instantly share code, notes, and snippets.

@pushrax
Created November 26, 2013 05:12
Show Gist options
  • Save pushrax/7653771 to your computer and use it in GitHub Desktop.
Save pushrax/7653771 to your computer and use it in GitHub Desktop.
class window.Testing extends Batman.App
data = []
class Testing.Storage extends Batman.StorageAdapter
readAll: @skipIfError (env, next) ->
env.result = env.records = @getRecordsFromData(data, env.subject)
next()
class Testing.Model extends Batman.Model
@persist Testing.Storage
class Testing.Order extends Testing.Model
@resourceName: 'order'
@encode 'id'
for i in [1...50]
@encode "#{i}"
@belongsTo 'customer', inverseof: 'orders', saveInline: true
class Testing.Customer extends Testing.Model
@resourceName: 'customer'
@encode 'id'
for i in [1...50]
@encode "#{i}"
@hasMany 'orders', inverseOf: 'customer', saveInline: false
for i in [0...50]
data[i] = id: i
for j in [1...50]
data[i][j] = "aaaaaaaaaaaaaaaaaaa"
data[i].customer = id: i
for j in [1...50]
data[i].customer[j] = "aaaaaaaaaaaaaaaaaaa"
console.log "stringified size:", JSON.stringify(data).length
document.addEventListener 'DOMContentLoaded', ->
Testing.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment