ngrest-db icon indicating copy to clipboard operation
ngrest-db copied to clipboard

mongoDB

Open jamesaxl opened this issue 7 years ago • 13 comments

what do you think about adding mongodb, i did some test and it works.

jamesaxl avatar Mar 12 '17 11:03 jamesaxl

Hmm, why not? Can I take a look on your implementation (pool request, please)?

loentar avatar Mar 12 '17 13:03 loentar

of Course, give me time please.

On Sun, Mar 12, 2017 at 4:10 PM, Dmitry [email protected] wrote:

Hmm, why not? Can I take a look on your implementation (pool request, please)?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/loentar/ngrest-db/issues/6#issuecomment-285943614, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOg9Mfvm9Cu-5mwrbMNfEeMfXQe3L6Vks5rk-6zgaJpZM4MahDm .

jamesaxl avatar Mar 12 '17 14:03 jamesaxl

could you show me the code that use for getting // *table: name and also field // *unique: true ? thankyou,

On Sun, Mar 12, 2017 at 5:10 PM, axl rose [email protected] wrote:

of Course, give me time please.

On Sun, Mar 12, 2017 at 4:10 PM, Dmitry [email protected] wrote:

Hmm, why not? Can I take a look on your implementation (pool request, please)?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/loentar/ngrest-db/issues/6#issuecomment-285943614, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOg9Mfvm9Cu-5mwrbMNfEeMfXQe3L6Vks5rk-6zgaJpZM4MahDm .

jamesaxl avatar Mar 14 '17 21:03 jamesaxl

Entity interface store such information. Implementation is code-generated at build time for every DB entity.

To get table name you can use entity.getTableName(), Example: https://github.com/loentar/ngrest-db/blob/master/drivers/sqlite/src/SQLiteDb.cpp#L272

To get access to field info Field interface is used, It's code-generated as well. See field.isUnique: https://github.com/loentar/ngrest-db/blob/master/drivers/sqlite/src/SQLiteDb.cpp#L252

Please also look to the whole getCreateTableQuery method, It uses all the meta-info passed from code-generator: https://github.com/loentar/ngrest-db/blob/master/drivers/sqlite/src/SQLiteDb.cpp#L237

Also please look to Entity https://github.com/loentar/ngrest-db/blob/master/common/src/Entity.h and Field https://github.com/loentar/ngrest-db/blob/master/common/src/Field.h

I think the easiest method to develop a new driver is to copy any existing, rename and modify it's implementation.

loentar avatar Mar 15 '17 07:03 loentar

yes that it is right, but Mongodb it a little different, it is nosql. I will implement anyway on the core of your repo and see how it will work. Thank you.

On Wed, Mar 15, 2017 at 10:00 AM, Dmitry [email protected] wrote:

Entity interface store such information. Implementation is code-generated at build time for every DB entity.

To get table name you can use entity.getTableName(), Example: https://github.com/loentar/ngrest-db/blob/master/drivers/ sqlite/src/SQLiteDb.cpp#L272

To get access to field info Field interface is used, It's code-generated as well. See field.isUnique: https://github.com/loentar/ngrest-db/blob/master/drivers/ sqlite/src/SQLiteDb.cpp#L252

Please also look to the whole getCreateTableQuery method, It uses all the meta-info passed from code-generator: https://github.com/loentar/ ngrest-db/blob/master/drivers/sqlite/src/SQLiteDb.cpp#L237

Also please look to Entity https://github.com/loentar/ ngrest-db/blob/master/common/src/Entity.h and Field https://github.com/loentar/ngrest-db/blob/master/common/ src/Field.h

I think the easiest method to develop a new driver is to copy any existing, rename and modify it's implementation.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/loentar/ngrest-db/issues/6#issuecomment-286657534, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOg9KxEzyJOo6FVh18OmQUE5JoBScQXks5rl4xygaJpZM4MahDm .

jamesaxl avatar Mar 15 '17 09:03 jamesaxl

Could you explain to me this code,

class NotesDb: public ::ngrest::DbManager< ::ngrest::PostgresDb > //is ::ngrest::DbManager map? { public: static NotesDb& inst() { static NotesDb instance; // ths instance is a DbManager instance or PostgresDb instance? return instance; }

thank you

jamesaxl avatar Mar 15 '17 20:03 jamesaxl

DbManager is a helper template class to store instance of db driver and to provide access to tables. You have to pass db driver class as template parameter to use it. All db drivers are inherited from Db class and provide the same interface. So if you implement a new db driver with the same interface, you just have to use it like DbManager<MongoDb> without any rewriting in ngrest-db code.

The static NotesDb& inst() is a singleton accessor with lazy creation. It's to have just one instance of db in memory. You have to call it like that: NotesDb::inst().db() - to get raw db instance, or NotesDb::inst().getTable<Notes>() - to get notes table.

loentar avatar Mar 15 '17 21:03 loentar

Thank you very much, I understand it very, the problem now is : MongoDB it is not a sql database manager it use bson for creating collection and document, i can not use DbManager, and if I want use it I should re-write it, and it is not good :), cause it works wotk this three database-manager very well , I am going to find how to implement on ngrest-db.

On Thu, Mar 16, 2017 at 12:15 AM, Dmitry [email protected] wrote:

DbManager is a helper template class to store instance of db driver and to provide access to tables. You have to pass db driver class as template parameter to use it. All db drivers are inherited from Db class and provide the same interface. So if you implement a new db driver with the same interface, you just have to use it like DbManager<MongoDb> without any rewriting in ngrest-db code.

The static NotesDb& inst() is a singleton accessor with lazy creation. It's to have just one instance of db in memory. You have to call it like that: NotesDb::inst().db() - to get raw db instance, or NotesDb::inst().getTable<Notes>() - to get notes table.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/loentar/ngrest-db/issues/6#issuecomment-286881667, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOg9FS4Oox7XHSmgPqtFxQbUCc-3TRkks5rmFTngaJpZM4MahDm .

jamesaxl avatar Mar 16 '17 18:03 jamesaxl

I'm afraid DbManager needs only few lines to change.

If you look into the Table class, you can see it contain many SQL code.. To add NoSQL support need to generalize Table into abstract class and derive implementation classes like SqlTable and NoSqlTable. Also Db will be split to SqlDb(which used with SqlTable) and NoSqlDb (for NoSqlTable).

So many changes.. I can try to do this work, but this will be not quick and if you can provide the MongoDB driver. Can you develop the NoSQL driver with methods which cover the Table functionality (select, insert, deleteWhere, etc.)? I will generalize Db and Table classes then.

loentar avatar Mar 16 '17 20:03 loentar

Hi, Do you join some channels in IRC? if yes could you tell me which one.

On Thu, Mar 16, 2017 at 11:14 PM, Dmitry [email protected] wrote:

I'm afraid DbManager needs only few lines to change.

If you look into the Table class, you can see it contain many SQL code.. To add NoSQL support need to generalize Table into abstract class and derive implementation classes like SqlTable and NoSqlTable. Also Db will be split to SqlDb(which used with SqlTable) and NoSqlDb (for NoSqlTable).

So many changes.. I can try to do this work, but this will be not quick and if you can provide the MongoDB driver. Can you develop the NoSQL driver with methods which cover the Table functionality (select, insert, deleteWhere, etc.)? I will generalize Db and Table classes then.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/loentar/ngrest-db/issues/6#issuecomment-287177765, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOg9NHifE_f90gzTD1IscfTfXmXeKzFks5rmZhAgaJpZM4MahDm .

jamesaxl avatar Mar 22 '17 17:03 jamesaxl

Sorry, I don't use IRC. Feel free to contact me via Email ([the same username as on github]@gmail.com) and Telegram ([the same username as on github]).

Also I created chat on gitter.im/ngrest

loentar avatar Mar 22 '17 18:03 loentar

Hello, Could i share your application on my repo https://fossil.falseking.site .

On Wed, Mar 22, 2017 at 9:01 PM, Dmitry [email protected] wrote:

Sorry, I don't use IRC. Feel free to contact me via Email ([the same username as on github]@ gmail.com) and Telegram ([the same username as on github]).

Also I created chat on gitter.im/ngrest

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/loentar/ngrest-db/issues/6#issuecomment-288486831, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOg9OAxivd0RHdBvJlgT_zvpzqNdoUHks5roWH0gaJpZM4MahDm .

jamesaxl avatar Apr 25 '17 11:04 jamesaxl

I'm not sure what you mean under "application", but if you mean this project or ngrest itself, you free to share it, it's under Apache 2 license.

loentar avatar Apr 25 '17 14:04 loentar