This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/couchbaselabs/go-couchbase" | |
"log" | |
) | |
func main() { | |
c, err := couchbase.Connect("http://localhost:8091") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_id": "_design/teams", | |
"language": "javascript", | |
"views": { | |
"all": { | |
"map": "function(doc, meta){ if(doc.type === 'team'){ emit(meta.id, null); } }" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get a number of unique account numbers via a map / reduce view | |
# | |
# foobar bucket contains: | |
# | |
# A = {"acct":"123456","name":"John Smith"} | |
# B = {"acct":"123456","name":"John Smith"} | |
# C = {"acct":"123457","name":"Jane Doe"} | |
# | |
# map: | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cb = new Couchbase("127.0.0.1:8091", "", "", "default"); | |
$cb->set("foo", "bar"); | |
var_dump("foo"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
;extension=php_exif.dll ; Must be after mbstring as it depends on it | |
extension=php_mysql.dll | |
extension=php_mysqli.dll | |
;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client | |
;extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client | |
;Couchbase | |
extension=php_couchbase.dll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def database | |
return @database if @database | |
manager = CBLManager.sharedInstance | |
error_ptr = Pointer.new(:object) | |
@database = manager.databaseNamed("todos", error: error_ptr) | |
unless @database | |
error = error_ptr[0] | |
alert = UIAlertView.alloc.initWithTitle("Local Database Error", | |
message:"No access to local database. #{error}", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def authenticate &block | |
account_store = ACAccountStore.alloc.init | |
fb_account_type = account_store.accountTypeWithAccountTypeIdentifier( ACAccountTypeIdentifierFacebook) | |
facebook_options = {} | |
facebook_options[ACFacebookAppIdKey] = @application_id | |
facebook_options[ACFacebookPermissionsKey] = ["email"] | |
account_store.requestAccessToAccountsWithType(fb_account_type, options:facebook_options, completion: lambda do |granted, error| | |
if granted | |
accounts = account_store.accountsWithAccountType(fb_account_type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def start_replication | |
@pull = @database.createPullReplication(sync_url) | |
@pull.continuous = true | |
@push = @database.createPushReplication(sync_url) | |
@push.continuous = true | |
listen_for_replication_events @pull | |
listen_for_replication_events @push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Item < CBLModel | |
attr_reader :created_at | |
def self.docType | |
"item" | |
end | |
def initInDatabase database, withTitle: title | |
self.initWithNewDocumentInDatabase database | |
self.setValue(self.class.docType, ofProperty: "type") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_item title | |
list = Item.alloc.initInDatabase(database, withTitle:title) | |
error_ptr = Pointer.new(:object) | |
list.save(error_ptr) | |
if error_ptr[0] | |
alert = UIAlertView.alloc.initWithTitle("Error", message: "Failed to create new item", delegate: nil, cancelButtonTitle: "Ok", otherButtonTitles: nil) | |
alert.show | |
else | |
list | |
end |
OlderNewer