Comments (16)
I added this: https://docs.strongloop.com/display/APIC/Model+definition+JSON+file#ModeldefinitionJSONfile-MySQLindexes
Please let me know if I need to add anything more (or change anything).
from loopback-connector-mysql.
Found so many bugs with indexes and mysql. For this specific use case, I found a work around (not documented). Convert yourindexes
property above to use columns
, rather than keys
, like this..
"indexes": {
"fripId_tagId_index": {
"columns": "fripId, tagId"
}
}
from loopback-connector-mysql.
@wrensburg it works. thanks!
from loopback-connector-mysql.
+1
For mysql I'm using:
"indexes":
{
"UNIQUE_REGISTRATION": {
"columns": "siteId,userId",
"kind": "unique"
}
},
works per this code: https://github.com/strongloop/loopback-connector-mysql/blob/master/lib/migration.js#L222-L243
from loopback-connector-mysql.
@saystone Has this been resolved? Can I close this?
from loopback-connector-mysql.
@superkhau Sorry for the late response. It was resolved. Btw I can't find strongloop documentation for create indexes on MySQL. Where can I find it? (https://docs.strongloop.com/display/public/LB/Model+definition+JSON+file#ModeldefinitionJSONfile-Indexes -> still different implemented loopback-connector-mysql code)
from loopback-connector-mysql.
@saystone No problem. I'm not sure where it's in the docs, but @crandmck would know.
from loopback-connector-mysql.
I don't think we have anything specific for creating MySQL indexes. This is for "auto-migration", right?
We have docs for that: https://docs.strongloop.com/display/LB/Creating+a+database+schema+from+models but nothing specific to MySQL.
Let me know if we need to add something.
from loopback-connector-mysql.
the keys
in the strongloop documentation has still not worked on the mysql connector.
from loopback-connector-mysql.
The comment above says:
It was resolved.
Which I thought meant that keys
now worked on MySQL. Is that not the case?
from loopback-connector-mysql.
No, It DOEST NOT work yet. The only way is a workaround: use the columns
instead.
from loopback-connector-mysql.
+1
Official Model definition JSON mention nowhere that there is a "columns"
property for "indexes": {}
definition, which is confusing, at least.
Manually writing "columns"
works, but is there anywhere documentation for this?
from loopback-connector-mysql.
and should tell people: the keys
does not work for mysql in the current version.
from loopback-connector-mysql.
Oh... Sorry for my miss communication.
I said 'It was resolved'. But I mean it's not for document. It means @wrensburg's solution.
Ultimately, The document was fixed correctly by @crandmck. But I think some additional comment for document. How can I contribute document?
from loopback-connector-mysql.
How can I contribute document?
@saystone Currently, the best way to contribute is to just suggest changes/additions in a GH issue (i.e. here) and I will make the change. We're working on getting the docs into a GH repo, but that's going to take quite a bit of time & work :-)
from loopback-connector-mysql.
I cannot get this to work. I defined
"indexes": {
"RANDOM_UNIQUE_INDEX": {
"columns": "account,order,filename",
"kind": "unique"
}
},
in my model and on autoupdate I get an error:
ErrorError: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order,filename)' at line 1
MySQL 5.7.19, "loopback-connector-mysql": "^5.2.0"
EDIT: fixed it by changing the colums line, notice the strange use of backward leaning quotes:
"columns": "`account`,`order`,`filename`",
Works though, I'll try and update the docs.
EDIT2: loopbackio/loopback.io#539
from loopback-connector-mysql.
Related Issues (20)
- AWS EC2 LoopBack Keep Connecting to 127.0.0.1 Even Already Specified RDS Endpoint HOT 6
- Tests are failing HOT 3
- Default Function UUID inconsistence HOT 1
- Connection to database hangs after Error: read ETIMEDOUT HOT 2
- Model's ID not set as private key in MySQL database
- RAW Query fails when server and DB are on differents IPs
- Fulltext index on a model property is not migrated to the datasource
- mysql.index is not work on property
- compatibility issue with mysql aurora 8.0.* using regex HOT 1
- n-gram specification on FULLTEXT index HOT 2
- Mapping of type blob/longblob to Binary fails the lb4 discover command HOT 1
- Fix CI pipeline HOT 1
- FULLTEXT | MYSQL | failed with status code 500. Error: ER_PARSE_ERROR: You have an error in your SQL syntax; HOT 1
- Add support for nodejs v18 and mysql v8 HOT 5
- Empty body on update generates an MySQL error HOT 2
- Support Latest Node 18 (LTS) HOT 1
- Dependency Dashboard
- Remove unknown options to the mysql2 initalizer HOT 3
- empty string is converted to empty object in LoopBack3
- getContext() gets lost when switching from mysql to mysql2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from loopback-connector-mysql.