delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

How can we create database/collections name from device side #95

Closed prasannakumark closed 8 years ago

prasannakumark commented 8 years ago

Hi All,

It may be a wrong question but i would like to ask. I do not know much about web development but using meteor i would like to develop my android application, I know very little about web.Coming to point, Is there any way to create database/collection name using android and also handle some validations which need handle in Nodejs(i mean something like simple schema and all), Let me explain with some code

TestDataBase = new Mongo.Collection('testdatabase');

TestDataBase.allow({
    insert: function(){
        return true;
    }
});
TestDataBase.allow({
    remove: function(){
        return true;
    }
});
TestDataBase.allow({
    update: function(){
        return true;
    }
});

if you've observed the above code, first I need to create the javascript code then only I can access in my android application for getting collections/database. In this time who do not know the javascript and all very difficult to understand and also we need to write same code for both web and mobile platforms.

Is it possibility to create database/collection name from the android side?. If you guys need any information/clarification please let me know. Why i am just asking is, previous i worked on _couchbase lite android _( of course that will support offline also may be reason why couhbase lite supporting) where i am able to creating my self database with auto replication(pull and push). Do we have any possibilities in meteor like this?

Thank's Prasnna Kumar

ocram commented 8 years ago

Thanks for your question!

Learning both web development and Meteor at the same time can be a lot of work. But for Meteor to work with Android (via this library), you don't need to know everything, fortunately.

If you know these things and if you understand every single character of your snippet, that's enough :)

So if you want to create a collection named testdatabase from Android, you have to create a method on the server (in JavaScript) that does this -- and then just call that method on Android (in Java). Your server-side method can do anything you want: You can just create the collection, but you can also populate it with initial data if you want, or insert some data to other (related) collections, etc.

If you want to access the data for that collection on Android, you have to subscribe to something you published on the server. So you may want to read about publish/subscribe with Meteor. And afterwards, you can use the database access classes from this library to see what your Android client received from the server.

To sum up, you have to write the server-side code in JavaScript because your server is a Meteor server and you can't use the Android client without any capable JavaScript server. But if you write the server-side code in JavaScript, you can have an Android client that has little code only and communicates with the server securely.

Does that help?

prasannakumark commented 8 years ago

Hi mwaclawek,

Thanks for your quick reply and clarification of my queries. Yeah, definitely it will help me lot and just i have to learn about basics of JavaScript and meteor server side code.Once again i would like to thanks for your quick reply.

ocram commented 8 years ago

You're welcome!

For future problems or questions please just open a new issue again :)