marcesher / cfmongodb

MongoDB client wrapper for ColdFusion
89 stars 34 forks source link

problems importing to mongo from a query #44

Open billieblaze opened 10 years ago

billieblaze commented 10 years ago

so, i've recently switched from the railo mongodb extension to cfmongodb because i'm having problems with my data landing in a proper mongodb format. I'm working on a routine which will perform a CFQUERY against a VisualFoxPro ODBC connection(barf), then stash the records in mongodb. the mongodb data will later be consumed by a nodeJS app. two problems i'm having

1) i was setting _id to a particular field in my db, for example, the old db has a "drivernumber" field, so i was feeding that into _id because on the nodeJS side, i'm using mongoose ODM to handle "joining" the data when needed. This field is essentially a string. it works in both the mongodb extension for railo and mongodb itself, but throws an error "invalid objectID".. Is that something i can work around with some modification?

2) this is the big one for me. I'm taking the cfquery results, iterating, converting to a struct (queryRowToStruct) and then stashing that in mongodb. I'm still getting string for everything. I've tried various javaCast and createObject(...javaDate..).init(mydate).. but its still landing as a string! further investigation indicates similar behavior is happening to ints as well.. Is it the fact that i'm converting to a struct? Also, can i feed a full query into some method in your wrapper?

any help would be great! i'm on the vere of just using epoch time, but i don't think that'll work quite right given the fact that it'd still be a string, mongo might not order it correctly..