Gun(options)
Used to creates a new gun database instance.
var gun = Gun(options)
note:
Gunworks with or without thenewoperator.
Options
no parameters
undefinedcreates a local datastore using the default persistence layer, either localStorage or a JSON file.passing a URL
stringcreates the above local datastore that also tries to sync with the URL.- or you can pass in an
arrayof URLs to sync with multiple peers.
- or you can pass in an
the previous options are actually aggregated into an
object, which you can pass in yourself.options.peersis an object, where the URLs are properties, and the value is an empty object.options.uuidallows you to override the default 24 random alphanumeric soul generator with your own function.options['module name']allows you to pass options to a 3rd party module. Their project README will likely list the exposed options. Here is a list of such modules...
Examples
Sync with one peer
Gun('http://yourdomain.com/gun')
Sync with many peers
Gun(['http://server1.com/gun', 'http://server2.com/gun'])
Working with modules
Gun({
// Amazon S3 (comes bundled)
s3: {
key: '',
secret: '',
bucket: ''
},
// simple JSON persistence (bundled)
// meant for ease of getting started
// NOT meant for production
file: 'file/path.json',
// set your own UUID function
uuid: function () {...}
})