-
Notifications
You must be signed in to change notification settings - Fork 579
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
Records not saved properly #104
Comments
when you do:
try |
that's a good idea, I have not thought about that. No it's full of empty values. this code: let acc = await this.props.database.collections.get('accounts').create(account => {
account.name = 'test';
account.initialBalance = 0.1;
account.currency = 'currency';
});
console.log(acc._raw); is producing this log:
That's what I don't get, the values are obviously recorded since on the view with the observable it works but because it's not saved properly, as soon as I reload the app I just get blank records. |
OK, I think I know what this is. I think you have misconfigured decorators support in your Babel config file. When you set Have you gone through Installation guide step by step? Do you have the "legacy" option for decorators set to true? |
Yes indeed you were right, I have something wrong setup in the babelrc, I close the issue :) Thanks a lot! :) |
@alex-min facing same issue can you show me your codes |
Please see #207 (comment) I had {
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [
["@babel/plugin-transform-flow-strip-types"],
["@babel/plugin-proposal-decorators", { "legacy": true }]
]
} instead of {
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-transform-runtime", {
"helpers": true,
"regenerator": false
}]
]
} in my babelrc. |
I had this issue too. Need to move
==>
|
I'm also running into this. schema import { appSchema, tableSchema } from '@nozbe/watermelondb';
export const schema = appSchema({
version: 5,
tables: [
tableSchema({
name: 'wallet',
columns: [
{ name: 'walletId', type: 'string', isIndexed: true },
{ name: 'currencyCodeStr', type: 'string', isIndexed: true },
],
}),
],
}); Model import { Model } from '@nozbe/watermelondb';
import { field } from '@nozbe/watermelondb/decorators';
export class WalletWMO extends Model {
static table = 'wallet';
@field('walletId')
walletId!: string;
@field('currencyCodeStr')
currencyCodeStr!: string;
} Code to insert database.write(async () => {
const table = database.get<WalletWMO>('wallet');
const result = await table.create((record: WalletWMO) => {
record.walletId = this.id;
record.currencyCodeStr = this.currencyCode.rawValue;
};);
}); And yet, the underlying `_raw values are empty/default Tsconfig has
BabelConfig has
|
Hello,
Thanks for all the work on the library, it's exactly what we need on react-native, the api & the code is slick :).
I have a very strange issue which is hard to debug, I spent about two days of debugging but I can't find the root cause of it. I used the examples/native as a base start of my project so everything is setup mostly the same way.
When I save a record, it works temporally (the observable query part works well) but it's not saved properly in the database, it just does not save data. So when I reload the app it does not work.
I've tried to debug watermelondb to find the root cause of it but I can't find why, what I know is that for some reason, the _raw object does not get set.
the model:
the schema file
the boot.js file
as you can see, everything is the same as the example project. I could also dump a copy of the whole repo if needed, there's nothing confidential in it, it's just a test.
to create the account I just do a
(the values are obviously normal, I've checked). And I do have this:
in the logs
it does work initially, you can see the new account in the view but when I reload the app, I just have an empty record from the database. I've also dumped the database and the records are indeed empty.
For the watermelondb version I've tried everything and it's still the same issue.
Does that sound like anything you have heard before?
The text was updated successfully, but these errors were encountered: