cutting-room-floor / backbone-couch Goto Github PK
View Code? Open in Web Editor NEWBackbone.js sync for CouchDB
Backbone.js sync for CouchDB
hi, please fix backbone-couch.js in 56 line:
change
data = [];
to
var data = [];
because it would generate some bug.
/*
* Backbone - CouchBD connection
*/
var connection = new cradle.Connection('http://localhost', 5984, {
auth: { username: 'admin', password: 'XXXXXXX' },
cache: true,
raw: false
});
// Create a new backbone-couch handler for a database 'mercado'.
var couch = require('backbone-couch')(connection, 'mercado');
// Create database, push default design documents to it and
// assign sync method to Backbone.
couch.install(function(err) {
Backbone.sync = couch('mercado').sync;
});
/ Users/aldo/Satio/Desarrollo/express/mercado/lib/backbone-couch.js:29
'Content-Length': data.length,
^
T ypeError: Cannot read property 'length' of undefined
at /Users/aldo/Satio/Desarrollo/express/mercado/lib/backbone-couch.js:29:43
at [object Object]. (fs.js:80:5)
at [object Object].emit (events.js:64:17)
at fs.js:819:12
I think it should be
Backbone.sync = couch.sync('documents');
otherwise couch function doesn't exist.
What it says.
run: npm test
it has error:
Error: Error: badarg
at /Users/Jackey/Workspace/embarq/node_modules/backbone-couch/test/test.js:9:23
at /Users/Jackey/Workspace/embarq/node_modules/backbone-couch/node_modules/backbone/backbone.js:1137:9
at /Users/Jackey/Workspace/embarq/node_modules/backbone-couch/backbone-couch.js:55:37
at [object Object].callback (/Users/Jackey/Workspace/embarq/node_modules/backbone-couch/couch.js:34:21)
at [object Object]. (/Users/Jackey/Workspace/embarq/node_modules/backbone-couch/node_modules/request/main.js:290:21)
at [object Object].emit (events.js:64:17)
at IncomingMessage. (/Users/Jackey/Workspace/embarq/node_modules/backbone-couch/node_modules/request/main.js:278:54)
at IncomingMessage.emit (events.js:81:20)
at HTTPParser.onMessageComplete (http.js:133:23)
at Socket.ondata (http.js:1228:22)
This is the output of couchDB:
[info] [<0.19199.2>] 127.0.0.1 - - 'PUT' /backbone_couch_test_custom/%2Fapi%2FNumber%2Ftwo 201
[error] [<0.19200.2>] Badarg error in HTTP request
[info] [<0.19200.2>] Stacktrace: [{erlang,iolist_to_binary,[true]},
{couch_httpd_rewrite,
'-maybe_encode_bindings/1-fun-0-',2},
{lists,foldl,3},
{couch_httpd_rewrite,handle_rewrite_req,3},
{couch_httpd_db,do_db_req,2},
{couch_httpd,handle_request_int,5},
{mochiweb_http,headers,5},
{proc_lib,init_p_do_apply,3}]
[info] [<0.19200.2>] 127.0.0.1 - - 'GET' /backbone_couch_test_custom/_design/backbone/_rewrite/api/Number/? 500
What's the couchDB version that project rely on ? I think the bug is from rewrite handler of couchDB.
I apologize if this isn't issue-worthy, but I can't figure out anywhere else to ask this question, so I'm creating an issue around it.
I have a small bones app that I'm trying use backbone-couch with, but whenever I call .save(), I get this error:
/vagrant/lgt-tim/node_modules/backbone-couch/backbone-couch.js:88
if (err) return error(err);
^
TypeError: undefined is not a function
I have no idea why this happens. I basically c/p'ed the code from the readme and nothing seems to be wrong. I've uninstalled and reinstalled. I have couchdb running. I'm out ideas. Help?
I have added auth options with username and password in couch.js. Let me know if you'd like me to do a pull request.
Currently only works with bones 1.x (#8). Since bones now has a stable 2.x release, add support for bones 2.x.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.