scootermaster
Platinum Member
So, here's the drill:
I have this URL that gives me JSON, but it's not guaranteed to be new JSON. I want to grab it and stick it in a CouchDB. Easy enough. But I obviously don't want duplicates.
I've looked at a few posts on StackExchange, but I was hoping for a little more clarity.
The JSON feed itself has an [increasing] burnedID (not the CouchDB _id) for each entry, which is handy (although the server's implementation of this is finicky, but that's their issue, not mine). I also looked in to adding a field via microtime(true), which seems to give me a big number that always increases.
But the actual implementation is sort of escaping me. I know I want to create a view -- which I can't seem to find a way of doing in PHP, since they have to be in JS, right? -- that gives me, say, the burnedIDs in decreasing order, look at the last one, and then only add the [new] incoming JSON if they're greater than that. Or does the view just give me the _ids of the documents in the CouchDB which match, and I then have to use those _ids to get the burnedID, and then check?
Am I overthinking this? Is there an easier way of doing this? I can't imagine I'm the first person to experience this, right?
Any help would be greatly appreciated, and let me know if you need more information.
I have this URL that gives me JSON, but it's not guaranteed to be new JSON. I want to grab it and stick it in a CouchDB. Easy enough. But I obviously don't want duplicates.
I've looked at a few posts on StackExchange, but I was hoping for a little more clarity.
The JSON feed itself has an [increasing] burnedID (not the CouchDB _id) for each entry, which is handy (although the server's implementation of this is finicky, but that's their issue, not mine). I also looked in to adding a field via microtime(true), which seems to give me a big number that always increases.
But the actual implementation is sort of escaping me. I know I want to create a view -- which I can't seem to find a way of doing in PHP, since they have to be in JS, right? -- that gives me, say, the burnedIDs in decreasing order, look at the last one, and then only add the [new] incoming JSON if they're greater than that. Or does the view just give me the _ids of the documents in the CouchDB which match, and I then have to use those _ids to get the burnedID, and then check?
Am I overthinking this? Is there an easier way of doing this? I can't imagine I'm the first person to experience this, right?
Any help would be greatly appreciated, and let me know if you need more information.