-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create many to many instance with id? #1241
Comments
Regarding to your question - checkout how to work with relational query builder. Regarding to your error - did you specify a reflect-metadata properly? Looks like it cannot get type reflection from your properties. |
thanks @pleerock for pointing out the doc. works perfectly:
for the error, do you refer to the option in tsconfig.json?:
I do have this option enabled, or is it something else? |
hi @pleerock, seems I have some problem with the addAndRemove call. let say originally I have two resources id 1 and 2. resource 1 has topics id 1 and 2, resource 2 has no topic. so the resource_topic table has the following record:
now I want to update resource 2 to have topics id 3 and 4, after I call:
the resource_topic table become:
i.e. the record for resource id 1 are wiped out. the reason I use addAndRemove and passing an empty array for removing ids is because if there were topics associated with resource I would like to remove the original ones also if I call
or
the whole resource_topic table is wiped out and become completely empty too. could you see what I did wrong here? |
Its not expected behaviour. If you send empty array it should not do anything. Fixed and will be released in 0.1.7 |
* master: fixed tslint error removed only test fixes #1270 webpack: enable usage in node projects by not automatically selecting browser version updated changelog fixes #1241 driver(cordova): support extra options remove only added tests for #1261 fixes #1259 fixes #1259 fixes #1254; version bump fixes #1254 # Conflicts: # CHANGELOG.md # package.json # src/entity-manager/EntityManager.ts
Hi,
Let say I have two classes:
and I would like to create a new Resource with two topics, and I already know the ids of the two topic (suppose they are 1, and 2), I am assuming I have to do:
is it possible to save the Resource without creating instances of Topic? or do I have to manipulate the 'resource_topic' table manually?
btw, if I omit the {type: 'varchar', length: 64} for the topic column and leave it just:
I got an error:
looks like the query is not specifying type of
topic
, I thought typeorm is going to infer that from the string type and make it varchar(255), am I missing some settings?The text was updated successfully, but these errors were encountered: