hipster - importing JDL - jhipster

I'm new to jhipster. so I'm sorry if the answer is obvious.
I'm trying to import my JDL with the command :
import-jdl ~/Downloads/jhipster-jdl.jh --debug
my JDL:
entity Package{
origin String,
destination String,
amORpm String,
department Integer,
weight Long,
barcode Long
}
entity Supplier {
regionName String required
}
entity Mission{
dueDate Instant required
}
entity Seller {
streetAddress String,
postalCode String,
city String,
stateProvince String,
phoneNumber String
}
entity WareHouse{
regionName String
}
entity Timer {
firstName String,
lastName String,
email String,
phoneNumber String,
hiringDate Instant required
}
entity GraphDataWeight {
effort Long
}
relationship OneToOne{
Mission {missionId} to Package
}
relationship OneToMany {
Supplier {packageId} to Package
Seller {sellerId} to Mission
Timer {timerId} to Mission
WareHouse {timerId} to Timer
GraphDataWeight {sellerId1} to Seller
GraphDataWeight {sellerId2} to Seller
}
paginate all with infinite-scroll
paginate all with pagination
dto * with mapstruct
Set service options to all except few
service all with serviceImpl
Set an angular suffix
angularSuffix * with mySuffix
the error I get:
The JDL is being parsed.
DEBUG! Error:
Error: The entity must be valid in order to be added.
Errors: The entity name cannot be a reserved keyword
tried all options that I found to fix it but I get the same error
at the begging I had an enum but I changed it just to get it to work. but I still get this error
I don't see any reserved words that I know of
thanks in advance for ur time

You cannot call an entity Package since it is a reserved keyword.
You also need to remove or comment out Set service options to all except few and Set an angular suffix to make it work.

Related

Creating entity relationship using a jdl in jhipster

I have the below JDL that I am using to create the jhipster application.
entity AuthClient(auth_client) {
msisdn String required maxlength(255),
email String required unique maxlength(255),
password String required maxlength(255),
lastLogin Instant,
createdAt Instant required,
createdBy Integer,
updatedAt Instant,
updatedBy Integer,
isDeleted Boolean required,
deletedAt Instant,
deletedBy Integer
}
entity AuthToken(auth_token) {
token String required maxlength(255),
appId Integer required,
appVersionName String maxlength(255),
clientId Integer required,
}
entity ClientProfile(client_profile) {
fName String required maxlength(255),
mName String maxlength(255),
lName String required maxlength(255),
gender Integer,
clientId Integer required
}
// Relations
relationship OneToMany {
AuthClient{AuthToken(clientId)} to AuthToken{AuthClient}
}
relationship OneToOne{
ClientProfile{AuthClient} to AuthClient{ClientProfile(clientId)},
}
// Options
service * with serviceClass
paginate * with pagination
dto * with mapstruct
filter *
However, instead of using the variable clientId as the foreign key it creates another field in the database.
I need to use the clientId as the foreign key in this application and not the generated new field Auth Client
Defining a clientId field as you did has no impact on the relationship, these are two separate things.
When you define a relationship, a field is automatically created in the entity and its type is of the related class: it's a reference to an object in the java entity and a foreign key column in the database table.
By default, the foreign key column will be named as auth_client_id and the field will be named as authClient. However, the JDL syntax for relationships lets you configure the relationship name and so modify the generated names.
So, remove all the clientId fields and modify your relationships definitions as follows:
// Relations
relationship OneToMany {
AuthClient to AuthToken{client}
}
relationship OneToOne{
ClientProfile{client} to AuthClient
}
This way you get the foreign key column named as client_id and the field named as client.
You can then define also which field of the related entity will be used for display in the generated UI.
There is more to learn about relationships in the doc: https://www.jhipster.tech/jdl/relationships

How to use aws amplify searchable to search multiple key of model?

I am using amplify graphql api. Where I have an Item model with different attributes.
I am trying to create an autocomplete or autosuggest api with user-added input.
type Item #model
#searchable
{
id: ID!
name: String!
description: String
category: String
fullAddress: String!
street: String
area: String
district: String
city: String
state: String!
zip: Int!
Right now I aam querying it like
query SearchEvent {
searchEvents(filter:{
name: {
ne: $query
}
}) {
items {
id
name
}
}
}
But this gives me only full word match to a particular key, like this example is match of name.
How do I query to get a response of any match or suggestions from any key of the item object?
For example, if my item name is Laptop and api query is la it should return the laptop item and other matching items name.
Likewise, if api query is ala it should return the Alabama, Alaska names including the item name matching with ala with a limit to 10 let's say.
Anyway is this possible? Any lead will eb helpful.

Why My jdl file is generating domains with error in code?

Hi I m using JHipster and doing some training in the jdl,
so while I generated a entity model from my jdl I got some code scaffolding errors, is this due to an error in my JDL or it is a issue in JHipster generator
entity Club{
federation String,
nomClub String,
dateFondation LocalDate
}
entity Boxeur {
nom String,
prenom String,
dateNaissance LocalDate,
lieuNaissance String,
dateInscription LocalDate
}
entity Entraineur{
nom String,
prenom String,
dateNaissance LocalDate,
lieuNaissance String,
president Boolean
}
enum LieuSeance {
SALLE,
STADE,
MONTAGNE,
AUTRE
}
entity TypeSeance{
typeSeance TypeSeance0
}
enum TypeSeance0 {
COMPETITION,
SPARRING,
ENDURANCE,
STREATCHING,
TECHNIQUE,
PHYSIQUE,
ENTRETIEN,
AUTRE
}
entity Seance{
titre String,
detail String,
dateSeance LocalDate,
lieu LieuSeance
}
entity Payement{
montant Long,
datePayement LocalDate
}
relationship OneToMany{
Entraineur{seances(titre)} to Seance{entreneur(nom)},
Boxeur{versement} to Payement,
TypeSeance to Seance
}
relationship OneToOne{
Club{president(nom)} to Entraineur
}
relationship ManyToMany{
Seance{participants(nom)} to Boxeur{assistes(titre)}
}
paginate all with pagination
dto * with mapstruct
service all with serviceImpl
the error is in the Seance.Java where add and remove participants got errors in scafolding like in the picture below
Did I make a mistake in my JDL file so I got this scafolding errors
Thanks you
I created an issue in JHipster
Issue Corrected in new release
for more info visit github issue tracker

How to get data from MySql relation table in Prisma

In datamodel.graphql
type Ride {
rideId: String
productId: String
passenger: Passenger
origin: Origin
destination: Destination
dateTime: DateTime
feedback: String
}
type Passenger {
id: ID! #unique
firstName: String
lastName: String
}
type Destination {
# The unique ID of the destination.
id: ID! #unique
latitude: Float
longitude: Float
address: String
}
type Origin {
id: ID! #unique
latitude: Float
longitude: Float
address: String
}
type Report {
productId: String
passenger: Passenger
description: String
}
I deployed this data model and generates a MySql Db, auto queries, mutations with this.
It creates a "Ride", "Passenger", "Report" and "Origin" table in MySql. But it didn't create any column for passenger, origin, destination in "Ride" table.
It separates creates a relation table for this like _PassengerToRide, _OriginToRide, and _DestinationToRide.
Lack of relation establishment in "Ride" table, I couldn't get the details from Passenger, Origin and Destination tables when I query "rides()". Is this the correct way to define the datamodel.graphql. (edited)
Based on your description, this query should "just work":
query {
rides {
feedback
passenger {
id
}
origin {
id
}
destination {
id
}
}
}
Prisma uses the relation table approach you mentioned to keep track if relations between two nodes, for example table _OriginToRide relates to relation #relation(name: "OriginToRide") from your datamodel.
You don't have to change anything on the SQL level to connect the relations afterwards.
Note: The above applies to Prisma database connectors with activated migrations. If your connector doesn't do migrations, different approaches to represent relations are supported. The respective datamodel to support this can be generated by introspecting your existing database schema.

mongoose: shorten attribute names of node.js models for storage

In C# it is possible to use the MongoDB driver to define a custom BSONElement Name to each attribute in your data model, in order to shorten its stored name, such as
[BsonElement("n")]
public String Name { get; set; }
Is there any way to accomplish this with mongoose for node.js in a model defined like
var Project = new Schema({
id : ObjectId,
name: String,
});
mongoose.model("Project", Project);
so that the attribute "name" will be stored as "n" and be referenced in code as "name"?
Researching the docs did not work very well on this one. Thanks!
There is a plugin where you can specify alias names, so that you can store single letter fields in the DB, but have really_long_names in your code:
https://github.com/ramiel/Alias-Field-Mongoose-plugin

Resources