Comments (13)
Can you make sure the collection does actually exist and that your syntax is correct?
The call(...)
method is used just like this in the source code of this library itself:
Moreover, the examples have a call to MongoDB's db.collection.count()
implemented with this library's call(...)
method:
from android-ddp.
This is my code:
if (meteor.isConnected()) {
meteor.loginWithEmail(email, password, new ResultListener() {
@Override
public void onSuccess(String result) {
Log.d(TAG, "Logged in: " + result);
try {
JSONObject login = new JSONObject(result);
String userId = login.getString("id");
String token = login.getString("token");
long expiry = login.getJSONObject("tokenExpires").getLong("$date");
Map<String, Object> user = new HashMap<String, Object>();
user.put("_id", userId);
Object[] queryParams = {user};
meteor.call("/Users/find", queryParams, new ResultListener() {
@Override
public void onSuccess(String result) {
Log.d(TAG, "Call result: " + result);
}
@Override
public void onError(String error, String reason, String details) {
Log.d(TAG, "Error: " + error + " " + reason + " " + details);
}
});
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onError(String error, String reason, String details) {
Log.d(TAG, "Error: " + error + " " + reason + " " + details);
}
});
}
from android-ddp.
Thanks for sharing the code!
There's nothing wrong with this library. It's just that Meteor doesn't offer find
to be called directly. The only methods you can call on a collection are insert
, update
and remove
. And for those, there are dedicated methods in this library so you don't need to use call(...)
.
Conceptually, retrieving data via find
is not how Meteor works. In Meteor, you subscribe
to data and the server pushes all changes to you via the callbacks of this library.
So instead of writing meteor.call("/Users/find", ...)
, you have to publish the data on the server and subscribe on the client with this library.
from android-ddp.
how do you handle meteor.call("/Users/find", ...) in server side?
when we use meteor.call so we must make meteor.method in server, right.. but I still don't understand in client it needs return data and the name of the meteor.call is "/user/find".
Is the name in meteor.method must /user/find too?
and how to handle return data ? Is the return data is json type?
Could you give some example please,,,
Thank you..
from android-ddp.
@isdzulqor as @mwaclawek said above, you can't use /Users/find
. What I do is subscribe to the data I want and save them to a local database, practically replicating the functionality of MiniMongo
meteor.setCallback(new MeteorCallback() {
// ...
@Override
public void onDataAdded(String collectionName, String documentID, String fieldsJson) {
// if documentID exists in the local db, update with the new data
// else insert the new data
}
// ...
});
from android-ddp.
@iahvector so it needs SQLite in your android native, and it needs to parse the JSON?
Is it correct?
from android-ddp.
Yes, though not necessarily SQLite, you can use any DB available on android. I personally use SQLite with an ORM. Sugar ORM is the easiest, and I'm currently experimenting with FlowDB as it it provides broader functionality.
from android-ddp.
@iahvector Thank you so much for sharing this, My english is still bad, so sometimes I feel hard to understanding the documentation of the library,, I will try that,,
Is it possible to upload file wtih this ddp library?
from android-ddp.
It can be, the guys at collectionFS do it, but I think it is complicated. When I needed to upload a file from android, I created a HTTP POST API for uploading files.
from android-ddp.
HTTP POST API with restivus? you use Meteor for server or php when it needs to upload file?
from android-ddp.
I use meteor.
from android-ddp.
@iahvector would you like to show me the code to make HTTP POST API to upload File like image? because I've implemented the tutorial from google but it's not working,
from android-ddp.
Thanks for the interesting discussion, @isdzulqor and @iahvector :)
But please try to open new issues for new problems and questions again :) The reason is that your questions and answer may really be helpful for other users and they may more easily find them if they are in separate issues.
Thank you!
from android-ddp.
Related Issues (20)
- Json result containing null value are converted to {"$InfNaN":0} HOT 5
- Notify only specific user HOT 1
- Switch to GSON HOT 3
- How to use android-ddp with requery HOT 1
- destroyInstance() breaks if not connected HOT 2
- Insert byte[] in collection HOT 3
- SubscribeListener does not has the callback response? HOT 3
- i cannot connect to server HOT 1
- wifi -> lte, when internet connection is changed, Connection timed out is occured immediately HOT 1
- Multi subscribe
- How to call methods with array of objects with keys HOT 1
- How to get collections without database HOT 1
- Is it possible to get a MongoDB database from the Meteor connection? HOT 1
- Manage susbscriptions after disconnect HOT 10
- Can you add a method to use a JSONObject or JSONArray or JSON String instead of an array of objects? HOT 1
- wss error handshake HOT 10
- I subscribe, I cancel the subscription and then I subscribe again and the OnDataAdded does not trigger
- Any listener (or method) to find out if all the subscribed data was received from server? HOT 2
- Is there any way to cancel the "call" request?
- Unable to use websocket connection over ssl HOT 2
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 android-ddp.