I am creating backend application in nestjs. I had many entities. for MVP we created project with some fields in entity class. now due to change in functionalities we added more columns in the entity class. I had my legacy migration file. now to add addtional column what should be my approach.
Should I delete existing migration file and create new one?
can I generate only incremental file because I dont want to lose existing data. I mean for additional column alter command.
How can I generate migration for incremental changes? I know how to crearte migration file for entirte entity.
thanks in advance.
Related
I'm new to React and was wondering if anyone had experience in using the React Flow library dynamically? As far as I can tell, the main way of using this library is to create a static .tsx file in the src/components/ directory.
I would like to use a JSON entry from my MongoDB and dynamically create a flow chart based on certain flags/values within React. If this is possible with React Flow, I'd appreciate a link or help! Thanks in advance.
That's absolutely possible.
As you can see in this example, node and edges are expressed as JSON: https://reactflow.dev/examples/edges/
You can modify the elements array at any time and add furhter elements by just adding simple JSON nodes.
On top of that you can autolayout your diagram: https://reactflow.dev/examples/layouting/
Check out the save and restore docs. You can save (or build your own) JSON representation of a workflow, then restore it as needed.
https://reactflow.dev/docs/examples/interaction/save-and-restore/
👋
Can anyone provide some hints how to solve the following problem with GatsbyJS:
I have a page, which is listing all the markdown files of the project, via this GraphQL query:
query ListQuery {
allMarkdownRemark(sort: {fields: frontmatter___date, order: DESC}) {
edges {
node {
id
html
frontmatter {
date(formatString: "DD.MM.YY")
docs
path
tag
title
}
}
}
}
}
If I'm right, it's not possible to set a dynamic filter which is binded to the search input field.
Later on I found this: https://www.gatsbyjs.org/docs/adding-search-with-js-search/
I thought js-search could be the solution, but then I need a big .json file. The problem: It's more comfortable to work with markdown files. So this doesn't look like the right solution either. 😞
I am thankful for help!
Quote from the docs
Before we go through the steps needed for adding client side search to
your Gatsby website, you should be familiar with the basics of Gatsby
Markdown and GraphQL are used during build phase, during creating your static site.
During run phase, during client search you don't have access GraphQL/Markdown. They are not exist during user interaction with your site.
So for client search, you should create need a big .json file. If you will follow the doc, it will not be problem for you.
Looks like I'm very late to answer this question, but it might be somewhat helpful for others looking for it.
Before adding search to gatsbyjs web app you should have some idea how gatsby builds the app. You can check it in the docs.
To add search you first need to create an index of all the markdown files. For creating an Index you can do it manually or can use search engines like aloglia, elastic search or lunr.js. If you want everything easy to manage you can go with aloglia which has a cap for free searches. If you want to go without spending any money you can go with lunrjs .
What these search engines will do is that they will create a data layer above the graphql data layer which can be used during the run time. You can then create node which can be used to query the posts in the app.This blogpost explains setting up search in gatsby with details.
So I deleted the file .tmp/localDiskDb.db manually and now when Sails generates it on start its empty, Is there a way to make Sails to recreate it based on my models?
As far as I understand, that file contains only your models' instances, i.e. your actual data. To make it have some data, just create some instances of your models and save them into the file database.
Deleting ./tmp/localDisk.db removes your data. I wouldn't actually use the default sails-disk as my adapter, if I were you. You should use a better DB (e.g mysql, sqlite, mongodb etc) that prevents issues like these. localDisk.db is literally a text file not isolated from your dev environment. you can see how this would be a problem.
use fixtures in your config/bootstrap to import "dummy" Data on Startup
I am building an application in Laravel 4. This application needs to be skinnable by the client. In essence, the owner of the app needs to be able to create his own template / styling / layout for his version, and upload it (ideally in a zip). Could you suggest any ideas / best practices / tips for building in functionality where this is possible?
Where should I locate the templates? Would you use the app/views folder or would you create a writable folder in the public folder?
Any ideas or suggestions or even links to a tutorial would be appreciated.
In a nutshell the way this is handled in Laravel is to use cascading views and a view namespace. Creating a namespace is easy, just pick a name and add the paths you want it to search in in the order of priority.
View::addNamespace('template', ['path/to/public/views', 'path/to/app/views']);
Now, when using View::make you can prefix with your namespace and it'll first search in path/to/public/views, if the view is not there it will then look in path/to/app/views. This is extremely handy when you want to provide a sort of base template and simply allow them to provide their own templates that overwrite the base.
Here is how you reference the namespaced views.
return View::make('template::example.view');
I'm using Swagger API documentation for my rest services. I have successfully integrated Swagger with my code and it works.
But I have a requirement to format the Swagger UI. Since the number of response classes are many in my project, the Swagger page looks very lengthy and the user has to scroll down a lot to view information.
So I want to collapse my response model classes and expand it when the user clicks the class. Is there a way to do it and if so where and what changes have to be made. I tried editing the Swagger-UI.js file but I could not achieve the needed output.
Please let me know and thanks in advance.
swagger-ui has the parameter docExpansion (see https://github.com/swagger-api/swagger-ui#parameters). Default is list, but if set it to none in the defaults section in src/core/index.js :
docExpansion: "none"
it will work and collapse everything when loading the site.
Swagger-UI.js is generated it would be very hard to modify Swagger UI by modifying this file.
If you want to customize SwaggerUI you should clone the github repository https://github.com/swagger-api/swagger-ui/ then modify files and rebuild it (you will then get a modified Swagger-UI.js and all other files).
Swagger-UI is composed of different views, each view having a js file and a handlebars template.
In your use case I'll try to modify these files:
src/main/template/signature.handlebars
src/main/javascript/view/SignatureView.js
To collapse swagger ui by default, you can use :
app = FastAPI(
swagger_ui_parameters = {"docExpansion":"none"},
...
)