Grails mongodb plugin configuration - mongodb

I use grails 2.5 and setup mongodb plugin. And there is the problem: when I try to save next object using console - all is ok, and empty strings saving as empty strings:
User {
name: "Hary",
lastname: ""
}
But when I try to save the same object via Idea using plugin listed above, it returns next:
User {
name: "Hary",
lastname: null
}
I understand, that mongodb plugin can converts empty strings to null, but I can't find solution for this problem.
Anyone know how can I solve it? Thanks!

Related

Kotlin changes parameter names to alphabetical values on release for a Flutter app

I recently started running into an issue, where, when building my Flutter in release mode to deploy to Play Console's internal testing track, some of my functions in Flutter started failing.
For context, I have EventChannels that stream data from a native function to Flutter, from which I construct a Flutter object.
After countless hours of investigation, it turned out that, in debug mode, the JSON string I'm constructing in Kotlin, contains the correct keys, however, when doing the same thing in release, the keys turn to a:, b:, c:, etc.
At this point in time, I've got no obfuscation enabled in the app, and I'm not too sure why this would have suddenly broke.
I can't cater for the actual names, and alphabetical values in my toJson() function on my class, so want to know how, in release, can I get my parameter values back?
The kotlin class that's encoded to JSON looks like this:
class ScanResponseModel(var name: String, var mac: String, var axis: String, var number : String)
The json output for this, in DEBUG, looks like this:
[{
"name":"2325",
"mac":"D4:1C:32:33:EE:1F",
"axis":"left",
"number":"0002325"
}, {
"name":"2122",
"mac":"DC:20:3F:E7:05:B7",
"axis":"right",
"number":"0002122"
}]
The exact same output in RELEASE, looks like this:
[{
"a":"2325",
"b":"D4:1C:32:33:EE:1F",
"c":"left",
"d":"0002325"
},
{
"a":"2122",
"b":"DC:20:3F:E7:05:B7",
"c":"right",
"d":"0002122"
}]

Meteor Angular2 and external changed of Mongodb

I play around with a simple Meteor Angular 2 app which only read from database. I have another app which change the database. But when the database is changed, I got error on Meteor app.
Exception in queued task: EXCEPTION: Error in client/match.html:0:19
ORIGINAL EXCEPTION: TypeError: Cannot read property 'league' of undefined
ORIGINAL STACKTRACE:
TypeError: Cannot read property 'league' of undefined
at DebugAppView._View_MatchComponent0.detectChangesInternal (MatchComponent.template.js:101:59)
at DebugAppView.AppView.detectChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57326:14)
at DebugAppView.detectChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57415:44)
at DebugAppView.AppView.detectViewChildrenChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57346:34)
at DebugAppView._View_MatchesComponent1.detectChangesInternal (MatchesComponent.template.js:106:8)
at DebugAppView.AppView.detectChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57326:14)
at DebugAppView.detectChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57415:44)
at DebugAppView.AppView.detectContentChildrenChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57341:37)
at DebugAppView._View_MatchesComponent0.detectChangesInternal (MatchesComponent.template.js:65:8)
at DebugAppView.AppView.detectChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57326:14)
ERROR CONTEXT:
[object Object]
I'm using autopublish which collection:
import {Mongo} from 'meteor/mongo';
export let MatchCollection = new Mongo.Collection('matches');
And angular component:
export class MatchesComponent
{
matches;
constructor() {
this.matches = MatchCollection.find();
}
}
Note: Meteor Blaze version works well. And I'm new to Meteor Angular2.
Thanks for all help.
I guess you are using *ngFor.
You can use this more stable way
this.matches = MatchCollection.find().fetch();
MatchCollection.find(); returns Mongo.Cursor<any>;
MatchCollection.find().fetch(); returns Array<any>
Weird, the bug should be already fixed...
It looks like the external change removed a property names league within the document, which your angular2 view uses somewhere.
Have a look at the document via meteor mongo to see how the document looks like in the storage before and after it has been modified by the external process.

MongoDB/Mongoose not saving nested properties

So I think I am doing something stupid, because I can't for the life of me get the following schema to work properly:
UserSchema = new mongoose.Schema
notifications:
discussion:
created:
mobile:
stuff:
hey:
type: Boolean
default: false
osx:
type: Boolean
default: false
web:
type: Boolean
default: true
email:
type: Boolean
default: true
sms:
type: Boolean
default: false
All looks normal, right? Just declaring some nested properties, their types, and their defaults? Nope.
Information.db.User.find {}, "notifications userSettings", (err, users) ->
for user in users
console.log user.notifications.discussion.created
// prints { mobile: { stuff: {} } }
All defaults gone, and the actual data I want to store is no where. Any ideas???
Edited to include the code for retrieving the user. Information.db.User is a refernce to the Mongoose Schema, skipping over my caching layer. The user already exists in the db, and I am trying to add the notifications object instead of having those settings stored as stringified JSON.
I'm pretty sure you have old user objects in your database that were created before you added the defaults or maybe they were left over from another project.
When I implemented your code in my test project I used an old database which already had existing users in it and got the same output as you did. I guess mongoose tries to force the schema on these user objects but it will only output the nested fields and none of the boolean fields since they are null.
When I created a new object with your schema it worked fine and I got values for all the default. Please let me know if this might have been the issue for you too.

Meteor.js - Publish function not working: Coffeescript

I am having some trouble making the publish function work with Meteor. The code I am using is as follows:
Meteor.publish "adminArea", () ->
Meteor.users.find({
admin: true
}, {
fields: {
permissions: 1
}
})
and I am subscribing with:
Meteor.subscribe "adminArea"
This doesn't work though, when I run Meteor.user() in the console it just returns the default options.
If I run db.users.find({"admin": "true"}) in Mongo the correct information is returned.
The annoying thing is, this used to work perfectly until I reset my database with Meteor reset. Would this be messing it up or does anyone know what I am doing wrong now?
Thanks for any help.
I have now fixed this issue and it was complete error on my part. I had forgot to add the permissions field to the user in the database so when it ran the query, it would find admin: true but then be unable to return the permissions field because it didn't exist.
So note to self: Always add the necessary fields to the user.
Oops!
Thanks

Issue with using polymorphic_path with FactoryGirl build object

I am using factory_girl and rspec2 for my testing. I have an issue with the following code:
let(:book) { build(:book, id: 1) }
book_path(book)
book_path statement is generating /books url instead of /books/1. I can use create, but any suggestions on how to fix this using build strategy?
I am using
rspec-rails (2.11.0)
factory_girl (3.5.0)
Try book.to_param (that's actually what book_path(book) is doing under the hood) and see what it returns. By default to_param returns id, but your book is not saved yet, so it can return nil.