Comments (6)
Hi @broerse, welcome to nodejs!
You can use async, which
provides straight-forward, powerful functions for working with asynchronous JavaScript.
With async.each()
(to handle the upload in paralell) or async.eachSeries()
(to push one file after the other) callback
is called when all files have been processed:
- distFiles.forEach(function (item) {
+ async.eachSeries(distFiles, function (item) {
//
+}, callback)
from couchdb-push.
Thanks but the problem seems to be that push is stopped because the script ends. Just tried RSVP but it does not help yet. It also does not wait?
upload: function(/* context */) {
var couchDir = this.readConfig('couchDir');
var db = this.readConfig('db');
var promise = new Promise(function(resolve, reject) {
push(db, couchDir, function(error, response) {
if(error) {
reject(response);
} else {
resolve('Upload OK');
}
});
});
promise.then(function(value) {
// on fulfillment
console.log(value);
}, function(reason) {
// on rejection
console.log(value);
});
console.log('zzzz');
},
from couchdb-push.
Have you tried to return the promise from the upload function?
from couchdb-push.
Yes I see the distFiles.forEach
is wrong. Thanks. I will test if it is the problem I have.
from couchdb-push.
No, I think I was wrong - I overread that didBuild
is sync because you used writeFileSync
. You maybe need to return a Promise from the upload
function like you wrote in the comment above.
from couchdb-push.
That was it:
upload: function(/* context */) {
var couchDir = this.readConfig('couchDir');
var db = this.readConfig('db');
var promise = new Promise(function(resolve, reject) {
push(db, couchDir, function(error, response) {
if(error) {
console.log('Error');
reject(response);
} else {
console.log('Upload OK');
resolve('Upload OK');
}
});
});
console.log('Start Upload');
return promise;
},
Many Thanks!!!
Just deployed: https://martinic.cloudant.com/emberapp/_design/deploytest1/_rewrite/
from couchdb-push.
Related Issues (20)
- It does not work with dbnames containing slashes HOT 1
- Update nano
- Calculate the _id from folder names if `_id` file is missing HOT 5
- Support for CommonJS within Couchdb - what am I missing? HOT 3
- Race condition
- Rename Repository
- Idea: Merge Hook
- Unable to use couchdb-push with basic authentication url's HOT 1
- Watch option HOT 1
- Handle database names with `/` in them HOT 5
- Support _bulk_docs format support HOT 1
- Correctly diff user docs
- Handle replication documents
- Supported node version HOT 2
- support handling json on the api
- here dont must return the other param from couchdb-ensure ?
- more of an help request really...
- {message: 'error happened in your connection', scope: 'socket', errid: 'request'} after changing to https HOT 5
- How to push a bunch of sample documents?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from couchdb-push.