Nozbe / WatermelonDB

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
https://watermelondb.dev
MIT License
10.62k stars 600 forks source link

Request for improved debug logs #30

Closed Kabangi closed 5 years ago

Kabangi commented 6 years ago

This is really a great project and am planning to use it in most of my upcoming projects.

While integrating it to an existing project I have run into this issue and I have no way of knowing what am doing wrong.

screen shot 2018-09-14 at 12 27 31 pm

Checking the swift line on the screenshot and without prior swift knowledge, I just can't figure out how to proceed.

This is my code:-

export default class Contact extends Model {
  static table = 'contacts';

  @field ('sid')
  id;
  @field ('username')
  username;
  @field ('email')
  email;
  @field ('first_name')
  firstName;
  @field ('middle_name')
  middleName;

  static makeContact = (db, c) =>
    db.collections.get ('contacts').prepareCreate (contact => {
      const n = transformRemoteContact (c);
      contact.sid = n.sid;
      contact.username = n.username;
      contact.email = n.email;
      contact.first_name = n.first_name;
    });

  // Model actions goes here.
  static async createContactsFromAPI (db, contacts) {
    const cont = transformRemoteContact (contacts[0]);
    const finalContacts = contacts.map (c => Contact.makeContact (db, c));
    console.warn (finalContacts[0]);
    return await db.batch (...finalContacts);
  }
}

Please help. Thanks.

radex commented 6 years ago

I'll take a look in a spare moment. I agree, the error logs could be more useful. I onlyy spotted one error:

contact.first_name = n.first_name

this should be contact.firstName. But I don't think it would throw in the database.

If you run the project from Xcode, and open the Xcode console logs, you should see more details there about the error (likely a SQL error). Let me know

Kabangi commented 6 years ago

Thanks, got it figured but I will leave this open since it's more generic and will help push for adoption of the project if done. Bump into another issue but I will file this as separate issue

radex commented 6 years ago

@Kabangi is this a solved issue?

Kabangi commented 6 years ago

From my end yes but I think the library need some love in that respect to help users spot errors much fast than the current state.

Solving this issue https://github.com/Nozbe/WatermelonDB/issues/42 might be the first step to that end

Am currently learning swift as an attempt to make a contribution to the library instead of requesting. Hoping I can pick up quickly and work on this and the issue attached her in.

radex commented 6 years ago

Sure, agreed! Let me know if you have specific troubles with contributing — and thanks for the interest!

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.