Skip to content
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

Delete a book using URL #161

Open
alex-alicunde opened this issue Nov 5, 2017 · 4 comments
Open

Delete a book using URL #161

alex-alicunde opened this issue Nov 5, 2017 · 4 comments

Comments

@alex-alicunde
Copy link

alex-alicunde commented Nov 5, 2017

I'm very new to Google's DataStore.

I want to make a list of my books with a button to delete the books I want.

But for this, I need to create a route to eliminate them:

$books= new GDS\Store('Book');	
foreach($books->fetchAll() as $book)
	{
		?>
			<h2><?php echo $book->title; ?> <a href="/delete/<?php echo $book->key; ?>">Delete</a></h2>
		<?php
	}

How do I create a route with the unique ID of the book ?. Is there any way to make automatic IDs ?.

@alex-alicunde
Copy link
Author

It is with $book->getKeyId() ?

That id is unique?

@alex-alicunde
Copy link
Author

And another silly question. The foreign keys do not exist ?.

Do I have to create them manually and do it by php always?

@tomwalder
Copy link
Owner

If you have inserted (upserted) without specifying a Key Name, then yes - getKeyID is the unique key.

@tomwalder
Copy link
Owner

Datastore supports a hierarchical reference system - ancestry.

If you just want reference entity "X" from entity "Y", then you are usually best to just store the Key ID (or name) in a string field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants