how i update inbuilt model (user) in strongLoop using mongodb? - node.js

enter image description here
i upload image here you can see whole folder structure..
In StrongLoop Framework there not visible User model in common/model folder so it's difficult to how i add property in user model?

You have to create a new model which inherits user model. You can only make the changes that model and not the existing user model.

Related

ASP.NET Core 6 Create data in the database with swagger

As it says in the title, I want to save data in the database by entering the data in the swagger, for this I made a service layer and controller and in the backend is the model and in frontend the dto.
Service Class
public async Task<SuperHeroDto> Create(SuperHeroDto dto)
{
#region
_firstAPIDatabaseContext.SuperHeroes.Add(dto);
var saveChangesAsync= await _firstAPIDatabaseContext.SaveChangesAsync();
}
I have the problem here:
_firstAPIDatabaseContext.SuperHeroes.Add(dto);
enter image description here
I want to learn it on my own, but need tips on how to do it.
I also created a profile for folders
I don't know the difference between SuperHeroDto and SuperHero in your code.
But obviously the code you provided is wrong to store SuperHeroDto objects in SuperHeroes.
Maybe you can write
_firstAPIDatabaseContext.SuperHeroeDto.Add(dto);

Sequelize afterFind hook in eager loading

I've two models User,Profile
I use eager loading to fetch user and it's profile.
But i need to attach image file names of every profile as an array to profile.
So when i want to fetch a profile independently, i can use FS.readDirSync to find profile files list and attach it to the Object as an array.
Is possible to do this in AfterFind hook in Sequelize and is it working in eager loading?

Do I have to add loopback-component-passport's core models manually?

I installed loopback-component-passport so I can use it with strongloop's Loopback framework. I followed the docs,
but after this command: npm install loopback-component-passport, the following files/models are not created:
UserIdentity model
UserCredential model
ApplicationCredential model
These files are used by Loopback for third-party authentication. Do I have to add them manually? Or am I doing something wrong?
Yes, you have to add them manually. You can refer this example, loopback-example-passport on github.
The reason is the relationships of loopback-component-passport's core models i.e UserIdentity model, UserCredential and ApplicationCredential with Loopback's core model AccessToken and User doesn't come preconfigured which is required for authentication.
Also, you might notice that the developer extended the models but didn't added any model.js. This is so because there was no need to add any runtime logic. For starters, you might want to extend the core models as per the example and create relationship and acls only. Then you can proceed with custom logic.
I think loopback built in models stay tucked away in node_modules, so assuming you mean that these tables are missing from your datastore, you can do an autoupdate in order to get loopback to build any missing tables.
I add the following code to a file in the server/boot directory when I need to during development.
module.exports = function(app, done) {
app.datasources.mysql_db.autoupdate(function(err) {
if (err) throw err;
console.log("autoupdate");
done();
})
}
Where mysql_db is the name of your datastore.
This will update the datasource when the server boot but shouldn't drop existing data (saying that I have seen instances where foreign keys are lost, so care & db backup is still needed).

Sails JS Model Rest API

I'm new to sails.js and find something strange. I have create a model user like :
sails generate api user
So i have access to :
http://localhost:1337/user/
and
http://localhost:1337/user/create?name=joe&test=true
But why sails allow me to add any fields I want in the model like :
http://localhost:1337/user/create?name=joe&test=true&toto=ok&titi=okToo
toto and okToo are not under my model in api/model/User.js:attributs
I miss something maybe if anyone can help me to understand this.
For me sails.js have to save only fields i put on model:attributs file or throw an exception
You can limit the creation of fields to only those you specific in the model. Sails has this feature to allow for quickly mocking up your site.
http://sailsjs.org/#/documentation/concepts/ORM/model-settings.html?q=schema

Extending the users package of mean.io

I am trying to create an application for sports event management system using MEAN.io
Since it uses the modular approach, there are different packages that comes in skeleton application like system, users, access. What i want to do is make a new package called players and it should extend the users package. The players schema would contain extra fields section and teams.So how do I extend the User Schema of users package in players package?
You can make your players package be dependent on users.
Players.register(function(app, auth, users, database) {...});
You now have access to the database and can load the user schema with
var userModel = database.connection.model('User');
and you can use the schema.add function to extend the schema
userModel.schema.add({ scrore: 'string'});
This should add the score field to the user model
I think this might work for you. But I was told from a member of mongoose team that schema.add only works before compiling the model. See this link for more info about schema add http://mongoosejs.com/docs/api.html#schema_Schema-add

Resources