waterline

Unique property fails in Sails.js

送分小仙女□ 提交于 2019-12-04 02:53:28
问题 The following code represents an Account Model in Sails.js v0.9.4 . module.exports = { attributes: { email: { type: 'email', unique: true, required: true }, password:{ type: 'string', minLength: 6, maxLength: 15, required:true } } }; When I send two POSTS and a PUT request via Postman to localhost:8080/account, the unique property of the email fails. Specifically, I send the following HTTP requests from Postman: POST http://localhost:8080/account?email=foo@gmail.com&password=123456 POST http:

Is it possible to rename `createdAt` and `updatedAt` in sails.js / waterline

こ雲淡風輕ζ 提交于 2019-12-04 02:34:00
Using Waterline ORM from SailsJS, my defaults for autoCreatedAt and autoUpdatedAt are set to false, but I still need to implement to the functionality just using different field names (DBA request). Is there a way to either: specify different column names for the automatically generated field, or manually emulate the same behave in an attribute definition, or can I just leave custom fields in the schema like created_ts and updated_ts to be updated with triggers in the DB schema itself (but I still need Waterline to read them)? Thanks in advance. Tristan Foureur I just opened two pull requests

Using sails.js with an existing postgres database

无人久伴 提交于 2019-12-04 00:30:35
I was looking at using Sails for an app that we are developing. I'm using the sails-postgresql adapter which uses the waterline orm. I have an existing database that I want to connect to. If I create a model using generate something and then in my model I have attributes:{ title:{type:'String'} } If I browse to localhost/something the orm deletes all the columns in the something table except title. Is there a way to stop it from doing this? This app should not delete columns on this database. Thanks! I am the author of Sails-Postgresql. Sails has an ORM called Waterline that it uses for

How to define instance methods for models with sails.js

隐身守侯 提交于 2019-12-04 00:18:40
问题 How can I define functions/instance method for objects in Sails ? In Waterline doc (https://github.com/balderdashy/waterline) they say: var User = Waterline.Collection.extend({ ... attributes: { ... // You can also define instance methods here fullName: function() { return this.firstName + ' ' + this.lastName } }, } But when I try do define an instance method in attributes in a model in Sails, the function is not added to the object. Am I doing something wrong ? Environment: Sails (v0.8.94),

I am confused with Sails.js waterline one-to-one association logic

断了今生、忘了曾经 提交于 2019-12-03 20:27:00
问题 So the reason why im confused, because I am a PHP developer and used Laravel and FuelPHP alot What i dont really understand is the association it self. What i mean, i wanted to create a basic hasOne / BelongsTo logic, with the following User has one profile Profile belongs to an user I am used to the following build up (Laravel style) Users table id | username | email | password --------------------------------------- 1 | My Username | My email | 1234568 Users_profile table user_id | first

Push values into array of mongodb database through (sails js) waterline

廉价感情. 提交于 2019-12-03 13:39:42
node js,sails js,waterline. I need to update(or push) values into the below schema after insert I am using sailsjs with waterline and mongodb. { "countries": { "states": [ { "statename": "state", "districts": [ { "distname": "district", "cities": [ { "cityname": "Hyderabad", "places": [ { "placename": "hitechcity" } ] } ] } ] } ] } } I need to know how to update it i need something like this after update { "countries": { "states": [ { "statename": "state", "districts": [ { "distname": "district", "cities": [ { "cityname": "Hyderabad", "places": [ { "placename": "hitechcity" }, { "placename":

Is it possible in Sailsjs to build more complex models

杀马特。学长 韩版系。学妹 提交于 2019-12-03 12:12:59
I would like to have arrays or collections in my model, is this yet possible with waterline (mongoDB)? are there any alternatives around? example: { name: Bundle, col1 : { name : anOtherModel, subCol: { text: aString, ... } }, col2 : { name : anOtherModel, subCol: { text: aString, ... } } } to: module.exports = { attributes : { name : { type : 'STRING', required : true }, basicModules: { type : 'ARRAY', // or 'COLLECTION' required : false } } }; I don't know if this is still an issue, but the trick is to neither POST as "form-data" nor "x-www-url-encoded". You have to POST the "raw" content:

How to Log in SailsJS

被刻印的时光 ゝ 提交于 2019-12-03 10:34:01
What is the actual syntax to log in SailsJS? Docs don't have anything, but found the following line in the site's roadmap "Pull out Sails.log (winston wrapper) as a separate module so it can be used by waterline" I image it's something like: Sails.log(...) Sails.error(...) Sails.warn(...) In your controllers, models, services, and anywhere else that the sails global is available, you can log with one of: sails.log(); sails.log.warn(); sails.log.info(); sails.log.debug(); sails.log.error(); sails.log.verbose(); sails.log.silly(); The logging level (that is, the level at which logs will be

npm install not installing latest version on GitHub

帅比萌擦擦* 提交于 2019-12-03 05:33:44
问题 I have a module called 'sails-mongo' and I want to update it to the newest version using the following command: npm update sails-mongo --save I also tried uninstall then install again. I tried sails-mongo@latest and sails-mongo@beta . Problem : The current version ( master ) on GitHub the package.json (https://github.com/balderdashy/sails-mongo/blob/master/package.json) file has: "dependencies": { "async": "~0.2.9", "lodash": "~2.4.1", "mongodb": "1.4.2", "waterline-errors": "~0.10.0" }, And

Sails.js best practice in using transactions with promises (Postgres)

一曲冷凌霜 提交于 2019-12-03 05:02:30
问题 I'm using sails 0.9.16 with Postgres and my question is: what is the best way to execute transaction using current API with promises? May be there is something better than: Model.query('BEGIN TRANSACTION', function (err) { if (err) { next(err); } else { Model .create(...) .(function (value) { return [value, RelatedModel.create(...).then(...)]; }) .fail(function (err) { Model.query('ROLLBACK'); next(err); }) .spread(function (...) { Model.query('COMMIT') next(...); }) } }) Thanks for help! 回答1