Giter Club home page Giter Club logo

Comments (13)

ocram avatar ocram commented on May 23, 2024

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:

call("/"+collectionName+"/remove", new Object[] { query }, listener);

Moreover, the examples have a call to MongoDB's db.collection.count() implemented with this library's call(...) method:

from android-ddp.

iahvector avatar iahvector commented on May 23, 2024

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.

ocram avatar ocram commented on May 23, 2024

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.

isdzulqor avatar isdzulqor commented on May 23, 2024

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.

iahvector avatar iahvector commented on May 23, 2024

@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.

isdzulqor avatar isdzulqor commented on May 23, 2024

@iahvector so it needs SQLite in your android native, and it needs to parse the JSON?
Is it correct?

from android-ddp.

iahvector avatar iahvector commented on May 23, 2024

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.

isdzulqor avatar isdzulqor commented on May 23, 2024

@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.

iahvector avatar iahvector commented on May 23, 2024

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.

isdzulqor avatar isdzulqor commented on May 23, 2024

HTTP POST API with restivus? you use Meteor for server or php when it needs to upload file?

from android-ddp.

iahvector avatar iahvector commented on May 23, 2024

I use meteor.

from android-ddp.

isdzulqor avatar isdzulqor commented on May 23, 2024

@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.

ocram avatar ocram commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.