Closed mikermcneil closed 10 years ago
Strong +1 for mongo here.
Another +1 for mongo support.
Hi,
Would be awesome to have a little example app on how associations work. I'm particularly interested on how they work on relational databases.
By the way, would be awesome if al the models where exposed in a HATEOAS REST API. What do you guys think?
I'm particularly interested on how they work on non-relational databases (MongoDB).
+1 for mongo support as well, by the way, sails is awesome!
MongoDB's embedded documents (non-relational) already works out-of-the-box using REST API blueprints + sails-mongo, totally awesome. Query using model works as well. I won't be here if the app doesn't require MySQL with loads of relations and accounting reports...
@ibrahimyu: could you gist an implementation of how you've managed to wrangle that together? I'd be curious to see
Hey @mikermcneil I'd like to help out move associations along. Currently development has been a bit closed and you have a 239 commit difference between master and associations branches. The waterline comparison is very similar. At the very least this needs a rebase to master to resolve the 31 or so commit difference. This makes figuring out what's changed more difficult than it needs to be.
Also it seems like quite a bit has been broken or changed in the associations branch and the version number has been bumped. Do you have a list of changes anywhere (other than the 200+ commits)?
Lastly could you give a brief status update or catch up on IRC at some point? This feature is rather important for us since right now we're using Ember Data to handle our relationships that are not consistently reflected in our server side ORM. I'm willing to put in time to write documentation and get some examples rolling.
@tbranyen: +1 to updating the folks in IRC... we're in here all day chattin' but don't see the devs enough! Come show us some love, some of us have expressed interest in helping with documentation and such but aren't sure where to start... plus we are all craving associations. Quite badly. @mikermcneil @particlebanana
+1 for love +1 for rebase
Same here, could help with whatever you guys need.
I am using backend mostly as REST API for my angular webapp and only have a few custom services. Would love to see sails been able to work that way so I can get rid of Spring (we get HATEOAS from Spring Data Rest).
I'd be willing to help too. Whats holding up this PR atm? Docs, tests, finding edge cases?
+1 for information on how to help.
@Latros I didn't do anything, just blank model + controller + sails-mongo adapter. GET, POST, PUT, DELETE using jQuery and everything works fine including embedded/nested documents.
+1 fort mongo. Thanks
I've given a try to associations both on postgresql and mysql. I don't know what I'm doing wrong when trying to post a new Reservation on wl-associations-playground project.
When doing this post ( I have a user with id=5 and place with id=1):
POST /reservation/ HTTP/1.1
Host: localhost:1337
Cache-Control: no-cache
{ "startDate" : "2013-01-01", "endDate": "2013-01-01", "user": 5, "place":1 }
I get the following error and sails stops itself:
debug: Lowering sails...
verbose: Sent kill signal to grunt child process...
verbose: Shutting down socket server...
/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/node_modules/pg/lib/client.js:160
throw error;
^
TypeError: Cannot call method 'toLowerCase' of undefined
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/lib/utils.js:373:30
at Array.forEach (native)
at Object.utils.buildSelectStatement (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/lib/utils.js:370:18)
at Query.find (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/lib/query.js:41:23)
at __FIND__ (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/lib/adapter.js:367:30)
at after (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/lib/adapter.js:509:7)
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/lib/adapter.js:495:7
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/node_modules/pg/lib/pool.js:55:9
at dispense (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/node_modules/pg/node_modules/generic-pool/lib/generic-pool.js:247:16)
at Object.me.acquire (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/node_modules/pg/node_modules/generic-pool/lib/generic-pool.js:316:5)
at Object.pool.connect (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/node_modules/pg/lib/pool.js:53:12)
at PG.connect (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/node_modules/pg/lib/index.js:37:8)
at spawnConnection (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/lib/adapter.js:494:8)
at Object.module.exports.adapter.find (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/lib/adapter.js:355:7)
at module.exports.find (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:20:18)
at module.exports.findOne (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:33:10)
at module.exports.findOne (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/basic.js:49:19)
at Deferred.exec (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/query/deferred.js:331:16)
at /Users/pablo/pruebas/wl-associations-playground/api/controllers/ReservationController.js:34:8
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/query/dql.js:152:11
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/async/lib/async.js:139:25
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/query/dql.js:142:13
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/utils/schema.js:141:39
at runner (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/query/dql.js:140:11)
at iterate (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/async/lib/async.js:131:13)
at Object.async.eachSeries (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/async/lib/async.js:147:9)
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/query/dql.js:147:15
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/lib/adapter.js:513:16
at __CREATE__ [as callback] (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/lib/adapter.js:306:11)
at Query.handleReadyForQuery (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/node_modules/pg/lib/query.js:80:10)
at null.<anonymous> (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/node_modules/pg/lib/client.js:151:26)
at EventEmitter.emit (events.js:117:20)
at null.<anonymous> (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:97:12)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at TCP.onread (net.js:526:21)
I think that it is similar to this: https://github.com/balderdashy/waterline-criteria/issues/13 ... alias is undefined.
I created an issue, Cody replied and I got it working with his recommendation: use the sails#multiassociations branch
On Dec 3, 2013, at 8:45 AM, "Martin Jantošovič" notifications@github.com wrote:
I think that it is similar to this: balderdashy/waterline-criteria#13 ... alias is undefined.
— Reply to this email directly or view it on GitHub.
I didn't know there was a multiassociations branch. I've just tried it out but I'm getting another error. By the way, I think sails sould be more fail tolerant and not stop abruptly when an error occurs.
verbose: Lowering sails...
verbose: Sent kill signal to child process (23544)...
verbose: Shutting down socket server...
TypeError: Cannot read property '__proto__' of undefined
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/defaultMethods/toObject.js:159:48
at Array.forEach (native)
at toObject.makeObject (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/defaultMethods/toObject.js:129:40)
at new module.exports (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/defaultMethods/toObject.js:35:8)
at _.extend.toObject (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/model/index.js:29:14)
at _.extend.toJSON (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/model/index.js:33:19)
at Object.stringify (native)
at ServerResponse.res.json (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/express/lib/response.js:189:19)
at /Users/pablo/pruebas/wl-associations-playground/api/controllers/ReservationController.js:36:13
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/basic.js:73:7
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:37:7
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/lib/adapter.js:567:24
at Object.adapter.releaseConnection (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/lib/adapter.js:75:11)
at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/lib/adapter.js:562:17
at Query._callback (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/lib/adapter.js:373:11)
at Query.Sequence.end (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Sequence.js:75:24)
at Query._handleFinalResultPacket (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Query.js:143:8)
at Query.EofPacket (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Query.js:127:8)
at Protocol._parsePacket (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:177:24)
at Parser.write (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Parser.js:62:12)
at Protocol.write (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:37:16)
at Socket.ondata (stream.js:51:26)
at Socket.EventEmitter.emit (events.js:117:20)
at Socket.<anonymous> (_stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at TCP.onread (net.js:526:21)
@pablocaselas Make sure to uninstall sails both globally and locally then reinstall using "npm install sails@git://github.com/balderdashy/sails.git#multiassociations". It would also be helpful if you posted your model and how you're trying to populate the data. Cheers.
On Dec 3, 2013, at 9:02 AM, "pablocaselas" notifications@github.com wrote:
I didn't know there was a multiassociations branch. I've just tried it out but I'm getting another error. By the way, I think sails sould be more fail tolerant and not stop abruptly when an error occurs.
verbose: Lowering sails... verbose: Sent kill signal to child process (23544)... verbose: Shutting down socket server...
TypeError: Cannot read property 'proto' of undefined at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/defaultMethods/toObject.js:159:48 at Array.forEach (native) at toObject.makeObject (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/defaultMethods/toObject.js:129:40) at new module.exports (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/nodemodules/waterline/lib/waterline/model/lib/defaultMethods/toObject.js:35:8) at .extend.toObject (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/nodemodules/waterline/lib/waterline/model/index.js:29:14) at .extend.toJSON (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/model/index.js:33:19) at Object.stringify (native) at ServerResponse.res.json (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/express/lib/response.js:189:19) at /Users/pablo/pruebas/wl-associations-playground/api/controllers/ReservationController.js:36:13 at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/basic.js:73:7 at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:37:7 at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/lib/adapter.js:567:24 at Object.adapter.releaseConnection (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/lib/adapter.js:75:11) at /Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/lib/adapter.js:562:17 at Query._callback (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/lib/adapter.js:373:11) at Query.Sequence.end (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Sequence.js:75:24) at Query._handleFinalResultPacket (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Query.js:143:8) at Query.EofPacket (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Query.js:127:8) at Protocol._parsePacket (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:177:24) at Parser.write (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Parser.js:62:12) at Protocol.write (/Users/pablo/pruebas/wl-associations-playground/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:37:16) at Socket.ondata (stream.js:51:26) at Socket.EventEmitter.emit (events.js:117:20) at Socket.
(_streamreadable.js:746:14) at Socket.EventEmitter.emit (events.js:92:17) at emitReadable (_stream_readable.js:408:10) at emitReadable (_stream_readable.js:404:5) at readableAddChunk (_stream_readable.js:165:9) at Socket.Readable.push (_stream_readable.js:127:10) at TCP.onread (net.js:526:21) — Reply to this email directly or view it on GitHub.
I removed sails locally, which was using associations branch. My current global sails is 0.9.7, why would I need to change it?
Regarding the models I am using the sample project @particlebanana wrote: https://github.com/particlebanana/wl-associations-playground/tree/master/api/models
I haven't done anything to the controllers so the population is the same as this:
create: function(req, res) {
if(!req.param('user')) return res.json({ error: 'Requires a User param'}, 400);
if(!req.param('place')) return res.json({ error: 'Requires a Place param'}, 400);
Reservation.create(req.body).exec(function(err, reservation) {
if(err) return res.json(err, 400);
// Lookup the new reservation and populate associations
Reservation.findOne(reservation.id)
.populate('user')
.populate('place')
.exec(function(err, reservation) {
if(err) return res.json(err, 400);
res.json(reservation);
});
});
},
As there is no documentation I am doing the post like I said before:
POST /reservation/ HTTP/1.1
Host: localhost:1337
Cache-Control: no-cache
{ "startDate" : "2013-01-01", "endDate": "2013-01-01", "user": 5, "place":1 }
is the syntax correct?
@pablocaselas I can't tell exactly what's wrong. I know it's happening during the call to res.json(...) - try logging the object before calling res.json to confirm it is retrieved from the database. If the object is undefined or null then there may have been an error when persisting the data.
@pablocaselas the standard association branch is currently broken. you need to use the waterline multi association branch with the sails-postgre associationsSSL branch.
https://github.com/balderdashy/sails-postgresql/commit/f71f4eda56c22d28edbf0a3bc943c29bae25df38
@snyx1 thank you very much! That did it! @lwansbrough you were right, it was creating the relationships on the table, but wasn't able to write it.
My syntax was right, for that matter (in case anyone bumps into this post having the same doubt).
PS: Is there any reason while waterline is not populating the data itself? I don't see why we need to create actions for this ourselves.
The same goes to the way we get stuff. I would like to have this kind of behaviour GET /user/1 will retrieve me the user without any collection the user model has, GET /user/1/ reservations will get me the user and its reservations. That doesn't work if you want more than one collection to be retrieved but could cover most cases pretty well, and you can always do your custom action to retrieve data as you like.
HATEOAS would be nice as well, but conventions could work out as well.
+1 for mongo associations! Sails is awesome!
+1 for mongo associations.
Yay! :+1:
:+1: for associations :)
Guys, it's moving along. @particlebanana and I just gave a preview at Node Summit, which we'll codify into a changelog over the next couple of weeks.
@tbranyen @betacar @Latros re: timeline for master & #associations diff.
You're right, I should have called the branch v0.10
:) Big todos before we can release (on the Sails side):
@mikermcneil I should PR Grunt improvements I've made to the multiassociations branch then?
I deleted my last post. Let me make this easier to understand; I think the multiAssociations branch is naming relations poorly. The naming pattern seems to be [association name]_[model name]_id
- why? Why not just name it [association name]
?
Question: Will it be possible to subscribe to an instance's children's class room via sockets?
For example: If I have a bunch of Users and Groups (A Group has many Users) can I subscribe to a 'class room' of a particular group's users vs. subscribing to all users?
+1 @davidbenhaim I had the same question. This may possibly be one of the most important features sails could incorporate into associations.
When it will be ready and put in production? +1 Mongo
Really looking forward to having associations in sails! I've currently "swapped" out Waterline for Sequelize until it is ready which means I am missing out on all the web socket goodies!
Is there a rough timeframe for when this will be released?
+1 for having this out the door ASAP. MySQL is what I need them for in my case (handling highly relational data in a social network). Going to write my own methods with Model.query
and raw SQL but of course that feels really kludgey. Would like to contribute/help in whatever way possible if @mikermcneil and @particlebanana have input on that.
I'm also looking forward to this feature. I think it will really complete things for me. Thanks for all the hard work guys.
With sailsjs@v0.10 getting
'Object #<Object> has no method \'forEach\''
anytime I make a call to index or show action using the default finder / crud api. Noticed this happens when I call the find or any of it siblings (findOne etal) on any model.
more details
error: Server Error (500)
error: TypeError: Object #<Object> has no method 'forEach'
at makeModels (/Sites/project/api/node_modules/waterline/lib/waterline/query/finders/joins.js:94:15)
at new module.exports (/Sites/project/api/node_modules/waterline/lib/waterline/query/finders/joins.js:23:22)
at /Sites/project/api/node_modules/waterline/lib/waterline/query/finders/basic.js:141:18
at /Sites/project/api/node_modules/waterline/lib/waterline/query/finders/operations.js:78:7
at Object.async.each (/Sites/project/api/node_modules/async/lib/async.js:104:20)
at /Sites/project/api/node_modules/waterline/lib/waterline/query/finders/operations.js:391:11
at /Sites/project/api/node_modules/waterline/lib/waterline/query/finders/operations.js:480:5
at Object.async.each (/Sites/project/api/node_modules/async/lib/async.js:104:20)
at _buildChildOpts (/Sites/project/api/node_modules/waterline/lib/waterline/query/finders/operations.js:418:9)
at _execChildOpts (/Sites/project/api/node_modules/waterline/lib/waterline/query/finders/operations.js:387:8)
at /Sites/project/api/node_modules/waterline/lib/waterline/query/finders/operations.js:76:10
at Database.select (/Sites/project/api/node_modules/sails-disk/lib/database.js:303:3)
at Object.module.exports.adapter.find (/Sites/project/api/node_modules/sails-disk/lib/adapter.js:47:16)
at module.exports.find (/Sites/project/api/node_modules/waterline/lib/waterline/adapter/dql.js:31:18)
at _runOperation (/Sites/project/api/node_modules/waterline/lib/waterline/query/finders/operations.js:366:18)
at run (/Sites/project/api/node_modules/waterline/lib/waterline/query/finders/operations.js:65:8)
at bound.module.exports.find (/Sites/project/api/node_modules/waterline/lib/waterline/query/finders/basic.js:136:16)
at bound [as find] (/Sites/project/api/node_modules/sails-util/node_modules/lodash/dist/lodash.js:729:21)
at Deferred.exec (/Sites/project/api/node_modules/waterline/lib/waterline/query/deferred.js:358:16)
at find (/Sites/project/api/api/blueprints/find.js:76:6)
at middlewareWrapper (/Sites/project/api/node_modules/sails/lib/router/bind.js:144:4)
at callbacks (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at param (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:135:11)
at pass (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:100:7)
at callbacks (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at _addResViewMethod (/Sites/project/api/node_modules/sails/lib/hooks/views/index.js:604:3)
at middlewareWrapper (/Sites/project/api/node_modules/sails/lib/router/bind.js:144:4)
at callbacks (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:100:7)
at callbacks (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at /Sites/project/api/node_modules/sails/lib/hooks/request/index.js:91:7
at /Sites/project/api/node_modules/sails/node_modules/connect-flash/lib/flash.js:21:5
at /Sites/project/api/node_modules/sails/lib/hooks/request/index.js:69:6
at middlewareWrapper (/Sites/project/api/node_modules/sails/lib/router/bind.js:144:4)
at callbacks (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:100:7)
at callbacks (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at /Sites/project/api/node_modules/sails/lib/hooks/i18n/index.js:36:7
at Object.i18nInit [as init] (/Sites/project/api/node_modules/sails/node_modules/i18n/i18n.js:80:5)
at routes.before./* (/Sites/project/api/node_modules/sails/lib/hooks/i18n/index.js:34:11)
at middlewareWrapper (/Sites/project/api/node_modules/sails/lib/router/bind.js:144:4)
at callbacks (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:100:7)
at callbacks (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
at routes.before./* (/Sites/project/api/node_modules/sails/lib/hooks/csrf/index.js:44:6)
at middlewareWrapper (/Sites/project/api/node_modules/sails/lib/router/bind.js:144:4)
at callbacks (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
at param (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
at pass (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
at Router._dispatch (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:173:5)
at Object.router (/Sites/project/api/node_modules/sails/node_modules/express/lib/router/index.js:33:10)
at next (/Sites/project/api/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:195:15)
at Object.handle (/Sites/project/api/node_modules/sails/lib/hooks/http/load.js:153:4)
at next (/Sites/project/api/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:195:15)
at Object.methodOverride [as handle] (/Sites/project/api/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js:48:5)
at next (/Sites/project/api/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:195:15)
at next (/Sites/project/api/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:197:9)
at Object._bodyParser [as handle] (/Sites/project/api/node_modules/sails/lib/hooks/http/bodyParser.js:45:12)
at next (/Sites/project/api/node_modules/sails/node_modules/express/node_modules/connect/lib/proto.js:195:15)
at next (/Sites/project/api/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/session.js:311:9)
at /Sites/project/api/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/session.js:335:9
at /Sites/project/api/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/session/memory.js:50:9
at process._tickDomainCallback (node.js:459:13)
my package.json
{
"name": "api",
"private": true,
"version": "0.0.0",
"description": "a Sails application",
"dependencies": {
"sails": "git://github.com/balderdashy/sails.git#v0.10",
"sails-disk": "git://github.com/balderdashy/sails-disk.git#associations",
"ejs": "0.8.4",
"grunt": "0.4.1",
"sails-memory": "git://github.com/balderdashy/sails-memory.git#associations",
"waterline": "git://github.com/balderdashy/waterline.git#multiAssociations",
"sails-mongo": "git://github.com/balderdashy/sails-mongo.git#associations",
"sails-redis": "0.0.0",
"sails-util": "~0.10.0",
"sails-postgresql": "~0.9.5",
"sails-mysql": "~0.9.7"
},
"scripts": {
"start": "node app.js",
"debug": "node debug app.js"
},
"main": "app.js",
"repository": "",
"author": "",
"license": ""
}
When I specified the table name, the error is now
error: TypeError: Object #<Object> has no method 'find'
Meaning its not even getting to waterline.
@casoetan v0.10 has been changing pretty rapidly, sorry about that. We'll be following up w/ official beta install instructions as soon as rough documentation is ready. Plenty of edge cases and error messages to improve, but all tests are currently passing.
I'm super excited about this. The usage looks pretty neat. Will the pubsub still work? As in, if a relation model updates, will we still be able to get updates?
+1 for Mongo
That would be great to have v0.10 , as i am eagerly waiting for associations in Waterline, the reason to switch to Sails was it is created for enterprise and none of the enterprise application can work without associations and relations.
Believe me i put my project on hold a month before and still waiting for the final release of v0.10 and yes node community loves you guys
Looking forward to this one. Maybe a write up on how to use other ORMs like for example node-orm2 in conjunction with Sails would solve many peoples problems.
node-orm2 is fantastic, and sometimes it is better to use existing tools and put them together in a framework instead of re inventing wheel.
Waterline is also good , but will take some time to work properly while fulfilling all requirements, so option of intergrating node-orm2 can be really helpful
@thetutlage that will be fantastic and it will make sails stronger and more flexible.
@connordev Associations must be bidirectional. Add a "store" or "stores" model/collection property to the User model
On Jan 11, 2014, at 11:06 AM, "connordev" notifications@github.com wrote:
I've ran into a problem testing out the associations, maybe I don't understand, but here's 2 models i have
// User Model module.exports = { attributes: { name: 'string' } };
// Store Model
module.exports = { attributes: { users: { collection: 'User' } } }; And I get this error when I lift the application
Error: Trying to associate a collection attribute to a model that doesn't have a Foreign Key. store is trying to reference a foreign key in user
Now there is no data, and I haven't tried to create any so why is it saying this?
— Reply to this email directly or view it on GitHub.
Hey guys... I'm running:
info: Sails.js
info: v0.9.8
can i get my current app running v0.10 ?
You can update sails in package.json to the v0.10 branch like so "sails": "git://github.com/balderdashy/sails.git#v0.10"
You will also need an adapter that works with associations like so "sails-disk": "git://github.com/balderdashy/sails-disk.git#associations"
This is all in development so expect breakage and changes until it is pushed to the main branch
Update:
Sails v0.10.0-rc3 is now available on npm.
We're working on improving docs in general, but we could really use your help- please feel free to submit pull requests to https://github.com/balderdashy/sails-docs. The changes go live to beta.sailsjs.org (and eventually sailsjs.org proper, when we set the
latest
tag on v0.10)